-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proposal: Check all types on lint-staged
- Loading branch information
Showing
1 changed file
with
1 addition
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,13 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
const _ = require( 'lodash' ); | ||
const path = require( 'path' ); | ||
const fs = require( 'fs' ); | ||
const execa = require( 'execa' ); | ||
|
||
/* eslint-disable no-console */ | ||
|
||
const repoRoot = path.join( __dirname, '..', '..' ); | ||
|
||
// lint-staged passes full paths to staged changes | ||
const changedFiles = process.argv.slice( 2 ); | ||
|
||
// Transform changed files to package directories containing tsconfig.json | ||
const changedPackages = _.uniq( | ||
changedFiles.map( ( fullPath ) => { | ||
const relativePath = path.relative( repoRoot, fullPath ); | ||
return path.join( ...relativePath.split( path.sep ).slice( 0, 2 ) ); | ||
} ) | ||
).filter( ( packageRoot ) => | ||
fs.existsSync( path.join( packageRoot, 'tsconfig.json' ) ) | ||
); | ||
|
||
try { | ||
execa.sync( 'npm', [ 'run', 'build:package-types', ...changedPackages ] ); | ||
execa.sync( 'npm', [ 'run', 'build:package-types' ] ); | ||
} catch ( err ) { | ||
console.error( err.message ); | ||
process.exitCode = 1; | ||
} | ||
|
||
/* eslint-enable no-console */ |