@nasl/cli 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -13396,7 +13396,7 @@ function fastLogToFile(entry, suffix, content) {
13396
13396
  const hourInDir = parseInt(timeInDir.slice(0, 2), 10);
13397
13397
  // 跨天则累加 24 小时
13398
13398
  const hourStr = (now.hour() >= hourInDir ? now.hour() : Math.ceil(hourInDir / 24) * 24 + now.hour()).toString().padStart(2, '0');
13399
- const entryName = sysPath.basename(Array.isArray(entry) ? entry[0] || '*' : entry).replace(/[\[\]\(\)\{\}\*\+\-\?\|\^\$\,\/\#\:\\\s]+/g, '_');
13399
+ const entryName = sysPath.basename(Array.isArray(entry) ? entry[0] || '*' : entry).replace(/[\[\]\(\)\{\}\+\-\*\?\|\^\$\#\:\,\\\/\s]+/g, '_');
13400
13400
  const filePath = sysPath.resolve(logDir, `${hourStr}${now.format('mmss_SSS')}-${entryName}-${suffix}`);
13401
13401
  libExports.outputFileSync(filePath, content);
13402
13402
  }
@@ -13490,7 +13490,14 @@ class ConsoleLogger extends BaseLogger {
13490
13490
  }
13491
13491
  }
13492
13492
  exit(code) {
13493
- process.exit(code);
13493
+ if (process.argv[1]?.endsWith('/nasl')) { // 添加保险措施,避免在非 CLI 环境下退出
13494
+ process.exit(code);
13495
+ }
13496
+ else {
13497
+ if (code)
13498
+ throw new Error(`Error with code: ${code}`);
13499
+ return undefined;
13500
+ }
13494
13501
  }
13495
13502
  }
13496
13503
  class ConsoleLoggerWithoutExit extends ConsoleLogger {
@@ -34499,7 +34506,7 @@ async function dev(entry, options) {
34499
34506
  // 有 src 目录,先进行一次初始编译
34500
34507
  logger.info('检测到 src 目录,开始初始编译...');
34501
34508
  try {
34502
- await compile(entry);
34509
+ await compile(entry, { logger });
34503
34510
  lastCompileSuccess = true;
34504
34511
  logger.success('初始编译成功!');
34505
34512
  }
@@ -34665,10 +34672,13 @@ async function startWebpackDevServer(outDir, options, logger) {
34665
34672
  webpackArgs += ` --port ${options.port}`;
34666
34673
  if (options?.host)
34667
34674
  webpackArgs += ` --host ${options.host}`;
34668
- if (options?.open)
34669
- webpackArgs += ' --open';
34670
- if (options?.hot)
34671
- webpackArgs += ' --hot';
34675
+ if (options?.open === false)
34676
+ webpackArgs += ' --no-open';
34677
+ if (options?.hot === false)
34678
+ webpackArgs += ' --no-hot';
34679
+ if (options?.publicPath)
34680
+ webpackArgs += ` --output-public-path "${options.publicPath}"`;
34681
+ logger?.info(webpackArgs);
34672
34682
  // 使用 spawn 而不是 spawnSync,以便进程可以常驻
34673
34683
  const webpackProcess = spawn(webpackArgs, {
34674
34684
  shell: true,