Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions make-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ var getCommonPackInfo = function (modOutDir) {
}
exports.getCommonPackInfo = getCommonPackInfo;

/**
* Performs npm audit on the specified task path.
* @param {string} taskPath - The path to the task directory where npm audit should be performed.
*/
function performNpmAudit(taskPath) {
console.log('\n🛫 Running npm audit...');

Expand All @@ -179,12 +183,12 @@ function performNpmAudit(taskPath) {
shell: true
});

if (auditResult.error) {
if (auditResult.status) {
console.log(`\x1b[A\x1b[K❌ npm audit failed because the build task at "${taskPath}" has vulnerable dependencies.`);
console.log('👉 Please see details by running the command');
console.log(`\tnpm audit --prefix ${taskPath}`);
console.log('or execute the command with --BypassNpmAudit argument to skip the auditing');
console.log(`\tnode make.js --build --task ${args.task} --BypassNpmAudit`);
console.log(`\tnode make.js build --task ${args.task} --BypassNpmAudit`);
process.exit(1);
} else {
console.log('\x1b[A\x1b[K✅ npm audit completed successfully.');
Expand All @@ -196,11 +200,24 @@ function performNpmAudit(taskPath) {
}
}

function getAdditionalTypeScriptArguments() {
const tsArgs = [];

if (process.argv.includes("--include-sourcemap")) {
tsArgs.push('--sourceMap');
}

return tsArgs.join('');
}

var buildNodeTask = function (taskPath, outDir, isServerBuild) {
var originalDir = shell.pwd().toString();
cd(taskPath);
var packageJsonPath = rp('package.json');
var overrideTscPath;

performNpmAudit(taskPath);

if (test('-f', packageJsonPath)) {
// verify no dev dependencies
// we allow only two dev dependencies: typescript and @tsconfig/node10
Expand Down Expand Up @@ -233,16 +250,14 @@ var buildNodeTask = function (taskPath, outDir, isServerBuild) {
cd(taskPath);
}

performNpmAudit(taskPath);

// Use the tsc version supplied by the task if it is available, otherwise use the global default.
if (overrideTscPath) {
var tscExec = path.join(overrideTscPath, "bin", "tsc");
run("node " + tscExec + ' --outDir "' + outDir + '" --rootDir "' + taskPath + '"');
run(`node ${tscExec} --outDir "${outDir}" --rootDir "${taskPath}" ${getAdditionalTypeScriptArguments()}`);
// Don't include typescript in node_modules
rm("-rf", overrideTscPath);
} else {
run('tsc --outDir "' + outDir + '" --rootDir "' + taskPath + '"');
run(`tsc --outDir "${outDir}" --rootDir "${taskPath}" ${getAdditionalTypeScriptArguments()}`);
}

cd(originalDir);
Expand Down
2 changes: 0 additions & 2 deletions make.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ var rm = util.rm;
var test = util.test;
var run = util.run;
var banner = util.banner;
var rp = util.rp;
var fail = util.fail;
var ensureExists = util.ensureExists;
var pathExists = util.pathExists;
var buildNodeTask = util.buildNodeTask;
var addPath = util.addPath;
var copyTaskResources = util.copyTaskResources;
Expand Down
Loading