@nstudio/schematics
Version:
Cross-platform (xplat) tools for Nx workspaces.
43 lines • 1.43 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @license
* Copyright (c) 2018 Narwhal Technologies Inc.
*
* Use of this source code is governed by an MIT- style license that can be
* found in the LICENSE file at https://github.com/nrwl/nx/blob/master/LICENSE
*/
const ast_1 = require("./ast");
const schematics_1 = require("@angular-devkit/schematics");
const literals_1 = require("@angular-devkit/core/src/utils/literals");
class FormatFiles {
toConfiguration() {
return {
name: 'node-package',
options: {
packageName: 'run format -- --untracked',
quiet: true
}
};
}
}
function formatFiles(options = { skipFormat: false }) {
if (options.skipFormat) {
return schematics_1.noop();
}
return (host, context) => {
const packageJson = ast_1.readJsonInTree(host, 'package.json');
if (packageJson.scripts && packageJson.scripts.format) {
context.addTask(new FormatFiles());
}
else {
context.logger.warn(literals_1.stripIndents `
Files were not formated during this code generation.
The "format" npm script is missing in your package.json.
Please either add a format script or pass --skip-format.
`);
}
};
}
exports.formatFiles = formatFiles;
//# sourceMappingURL=format-files.js.map
;