Skip to content

Commit

Permalink
Add more options to grunt generate-phet-io-api, see generate-phet-io-api
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Apr 7, 2021
1 parent afdde02 commit 64b76d5
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions js/grunt/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,16 @@ Updates the normal automatically-generated files for this repository. Includes:

grunt.registerTask(
'generate-phet-io-api',
'Output the phet-io API as JSON to phet-io/api.',
'Output the phet-io API as JSON to phet-io/api.\n' +
'Options\n:' +
'--sims=... a list of sims to compare (defaults to the sim in the current dir)\n' +
'--simList=... a file with a list of sims to compare (defaults to the sim in the current dir)\n' +
'--temporary - outputs to the temporary directory',
wrapTask( async () => {

const dir = '../phet-io/api/';
const sims = getSimList().length === 0 ? [ repo ] : getSimList();

const dir = grunt.option( 'temporary' ) ? '../phet-io/api-temporary' : '../phet-io/api';
try {
fs.mkdirSync( dir );
}
Expand All @@ -490,10 +496,15 @@ Updates the normal automatically-generated files for this repository. Includes:
throw e;
}
}
const filePath = `../phet-io/api/${repo}.json`;

const api = ( await generatePhetioMacroAPI( [ repo ] ) )[ repo ];
fs.writeFileSync( filePath, formatPhetioAPI( api ) );
const results = await generatePhetioMacroAPI( sims, {
showProgressBar: sims.length > 1
} );
sims.forEach( sim => {
const filePath = `${dir}/${sim}.json`;
const api = results[ sim ];
fs.writeFileSync( filePath, formatPhetioAPI( api ) );
} );
} )
);

Expand Down

1 comment on commit 64b76d5

@samreid
Copy link
Member Author

@samreid samreid commented on 64b76d5 Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #1025

Please sign in to comment.