Skip to content

Commit

Permalink
Add back format-js with a deprecation note
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Mar 26, 2021
1 parent 193fcd7 commit 09dee95
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
"fixtures:generate": "cross-env GENERATE_MISSING_FIXTURES=y npm run test-unit",
"fixtures:regenerate": "npm run fixtures:clean && npm run fixtures:generate",
"format": "wp-scripts format",
"format-js": "wp-scripts format-js",
"format-php": "wp-env run composer run-script format",
"lint": "concurrently \"npm run lint-lockfile\" \"npm run lint-js\" \"npm run lint-pkg-json\" \"npm run lint-css\"",
"lint-js": "wp-scripts lint-js",
Expand Down
36 changes: 36 additions & 0 deletions packages/scripts/scripts/format-js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* External dependencies
*/
const chalk = require( 'chalk' );

/**
* Internal dependencies
*/
const { getNodeArgsFromCLI, spawnScript } = require( '../utils' );

const { scriptArgs, nodeArgs } = getNodeArgsFromCLI();

const keypress = async () => {
process.stdin.setRawMode( true );
return new Promise( ( resolve ) =>
process.stdin.once( 'data', () => {
process.stdin.setRawMode( false );
resolve();
} )
);
};

( async () => {
const message =
`Please note that the ${ chalk.red(
'format-js'
) } script has been renamed to ${ chalk.green( 'format' ) }.\n` +
"If you're calling it from any of your own scripts, please update them accordingly.\n" +
'Press any key to continiue.';

// eslint-disable-next-line no-console
console.log( message );

await keypress();
spawnScript( 'format', scriptArgs, nodeArgs );
} )();

0 comments on commit 09dee95

Please sign in to comment.