Skip to content

Commit

Permalink
Proposal: Check all types on lint-staged
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Mar 25, 2020
1 parent a3598cc commit 51195f3
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions bin/packages/lint-staged-typecheck.js
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 */

0 comments on commit 51195f3

Please sign in to comment.