Skip to content
This repository has been archived by the owner on Jul 9, 2018. It is now read-only.

Commit

Permalink
Add a check for package.json to include a publishConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
pento committed Apr 25, 2018
1 parent 3187f5b commit 9af1934
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const BUILD_DIR = {
module: 'build-module',
};
const DONE = chalk.reset.inverse.bold.green( ' DONE ' );
const ERROR = chalk.reset.inverse.bold.red( ' ERROR ' );

/**
* Babel Configuration
Expand Down Expand Up @@ -128,11 +129,18 @@ function buildFileFor( file, silent, environment ) {
*/
function buildPackage( packagePath ) {
const srcDir = path.resolve( packagePath, SRC_DIR );
const packageFile = packagePath + '/package.json';
const files = glob.sync( srcDir + '/**/*.js', { nodir: true } )
.filter( file => ! /\.test\.js/.test( file ) );

process.stdout.write( `${ path.basename( packagePath ) }\n` );

const config = require( packageFile );
if ( ! config.publishConfig || 'public' !== config.publishConfig.access ) {
process.stdout.write( `${ ERROR } package.json must include "publishConfig": { "access": "public" }\n` );
process.exitCode = 1;
}

files.forEach( file => buildFile( file, true ) );
process.stdout.write( `${ DONE }\n` );
}
Expand Down

0 comments on commit 9af1934

Please sign in to comment.