@@ -159,6 +159,10 @@ var getCommonPackInfo = function (modOutDir) {
159
159
}
160
160
exports . getCommonPackInfo = getCommonPackInfo ;
161
161
162
+ /**
163
+ * Performs npm audit on the specified task path.
164
+ * @param {string } taskPath - The path to the task directory where npm audit should be performed.
165
+ */
162
166
function performNpmAudit ( taskPath ) {
163
167
console . log ( '\n🛫 Running npm audit...' ) ;
164
168
@@ -179,12 +183,12 @@ function performNpmAudit(taskPath) {
179
183
shell : true
180
184
} ) ;
181
185
182
- if ( auditResult . error ) {
186
+ if ( auditResult . status ) {
183
187
console . log ( `\x1b[A\x1b[K❌ npm audit failed because the build task at "${ taskPath } " has vulnerable dependencies.` ) ;
184
188
console . log ( '👉 Please see details by running the command' ) ;
185
189
console . log ( `\tnpm audit --prefix ${ taskPath } ` ) ;
186
190
console . log ( 'or execute the command with --BypassNpmAudit argument to skip the auditing' ) ;
187
- console . log ( `\tnode make.js -- build --task ${ args . task } --BypassNpmAudit` ) ;
191
+ console . log ( `\tnode make.js build --task ${ args . task } --BypassNpmAudit` ) ;
188
192
process . exit ( 1 ) ;
189
193
} else {
190
194
console . log ( '\x1b[A\x1b[K✅ npm audit completed successfully.' ) ;
@@ -196,11 +200,24 @@ function performNpmAudit(taskPath) {
196
200
}
197
201
}
198
202
203
+ function getAdditionalTypeScriptArguments ( ) {
204
+ const tsArgs = [ ] ;
205
+
206
+ if ( process . argv . includes ( "--include-sourcemap" ) ) {
207
+ tsArgs . push ( '--sourceMap' ) ;
208
+ }
209
+
210
+ return tsArgs . join ( '' ) ;
211
+ }
212
+
199
213
var buildNodeTask = function ( taskPath , outDir , isServerBuild ) {
200
214
var originalDir = shell . pwd ( ) . toString ( ) ;
201
215
cd ( taskPath ) ;
202
216
var packageJsonPath = rp ( 'package.json' ) ;
203
217
var overrideTscPath ;
218
+
219
+ performNpmAudit ( taskPath ) ;
220
+
204
221
if ( test ( '-f' , packageJsonPath ) ) {
205
222
// verify no dev dependencies
206
223
// we allow only two dev dependencies: typescript and @tsconfig /node10
@@ -233,16 +250,14 @@ var buildNodeTask = function (taskPath, outDir, isServerBuild) {
233
250
cd ( taskPath ) ;
234
251
}
235
252
236
- performNpmAudit ( taskPath ) ;
237
-
238
253
// Use the tsc version supplied by the task if it is available, otherwise use the global default.
239
254
if ( overrideTscPath ) {
240
255
var tscExec = path . join ( overrideTscPath , "bin" , "tsc" ) ;
241
- run ( " node " + tscExec + ' --outDir "' + outDir + ' " --rootDir "' + taskPath + '"' ) ;
256
+ run ( ` node ${ tscExec } --outDir "${ outDir } " --rootDir "${ taskPath } " ${ getAdditionalTypeScriptArguments ( ) } ` ) ;
242
257
// Don't include typescript in node_modules
243
258
rm ( "-rf" , overrideTscPath ) ;
244
259
} else {
245
- run ( ' tsc --outDir "' + outDir + ' " --rootDir "' + taskPath + '"' ) ;
260
+ run ( ` tsc --outDir "${ outDir } " --rootDir "${ taskPath } " ${ getAdditionalTypeScriptArguments ( ) } ` ) ;
246
261
}
247
262
248
263
cd ( originalDir ) ;
0 commit comments