piral-cli
Version:
The standard CLI for creating and building a Piral instance or a Pilet.
32 lines • 1.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;
const common_1 = require("../common");
/**
* Checks if the used Piral instance is not referenced in the code.
*/
async function default_1(context, options = 'ignore') {
if (options !== 'ignore') {
const { name } = context.apps[0].appPackage;
const names = ['piral', 'piral-core', 'piral-base', name];
const files = await (0, common_1.getSourceFiles)(context.entry);
const testers = [];
for (const packageName of names) {
testers.push(new RegExp(`(import\\s+.*\\s+from\\s+["'\`]${packageName}["'\`]|require\\(["'\`]${packageName}["'\`]\\));`));
}
for (const file of files) {
const fileContent = await file.read();
for (const tester of testers) {
if (tester.test(fileContent)) {
context.error(`
The Piral instance is referenced in "${file.path}".
Expected: No import of "${name}" or Piral itself.
Received: Import seen.
`);
break;
}
}
}
}
}
//# sourceMappingURL=pilet-has-no-self-reference.js.map