-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.js
42 lines (34 loc) · 1.36 KB
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2017, University of Colorado Boulder
/**
* Builds a repository.
*
* @author Jonathan Olson <[email protected]>
*/
const ChipperVersion = require( './ChipperVersion' );
const execute = require( './execute' ).default;
const getBuildArguments = require( './getBuildArguments' );
const gruntCommand = require( './gruntCommand' );
const fs = require( 'fs' );
const winston = require( 'winston' );
/**
* Builds a repository.
* @public
*
* @param {string} repo
* @param {Object} [options]
* @returns {Promise.<string>} - The stdout of the build
*/
module.exports = async function build( repo, options ) {
winston.info( `building ${repo}` );
const chipperVersion = ChipperVersion.getFromRepository();
const args = getBuildArguments( chipperVersion, options );
const result = await execute( gruntCommand, args, `../${repo}` );
const packageObject = JSON.parse( fs.readFileSync( `../${repo}/package.json`, 'utf8' ) );
const includesPhetio = packageObject.phet && packageObject.phet.supportedBrands && packageObject.phet.supportedBrands.includes( 'phet-io' );
// Examine output to see if getDependencies (in chipper) notices any missing phet-io things.
// Fail out if so. Detects that specific error message.
if ( includesPhetio && result.includes( 'WARNING404' ) ) {
throw new Error( 'phet-io dependencies missing' );
}
return result;
};