Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
}
const ignoreArgs = [ '--ignore-path', ignorePath ];
// forward the --require-pragma option that formats only files that already have the @format
// pragma in the first docblock.
const pragmaArgs = hasArgInCLI( '--require-pragma' ) ? [ '--require-pragma' ] : [];
// Get the files and directories to format and convert them to globs
let fileArgs = getFileArgsFromCLI();
if ( fileArgs.length === 0 ) {
fileArgs = [ '.' ];
}
// Converts `foo/bar` directory to `foo/bar/**/*.js`
const globArgs = dirGlob( fileArgs, { extensions: [ 'js' ] } );
const result = spawn(
resolveBin( 'prettier' ),
[ '--write', ...ignoreArgs, ...pragmaArgs, ...globArgs ],
{ stdio: 'inherit' }
);
process.exit( result.status );
const globToTask = task => glob => {
const {options} = task;
if (options.ignore && Array.isArray(options.ignore) && options.expandDirectories) {
options.ignore = dirGlob.sync(options.ignore);
}
return {
pattern: glob,
options
};
};