milkee 2.0.0 → 2.0.1

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.
Files changed (2) hide show
  1. package/dist/main.js +24 -16
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -156,7 +156,7 @@
156
156
  };
157
157
 
158
158
  compile = async function() {
159
- var compilerProcess, config, debounceTimeout, enabledOptions, enabledOptionsList, error, execCommand, execCommandParts, execOtherOptionStrings, i, item, itemPath, items, lastError, len, milkee, milkeeOptions, options, optionsForPlugins, spawnArgs, summary, targetDir, toContinue;
159
+ var compilerProcess, config, debounceTimeout, enabledOptions, enabledOptionsList, error, execCommand, execCommandParts, execOtherOptionStrings, i, item, itemPath, items, lastError, len, milkee, milkeeOptions, options, spawnArgs, stat, summary, targetDir, toContinue;
160
160
  checkCoffee();
161
161
  if (!fs.existsSync(CONFIG_PATH)) {
162
162
  consola.error(`\`${CONFIG_FILE}\` not found in this directory: ${CWD}`);
@@ -169,7 +169,7 @@
169
169
  consola.error('`entry` and `output` properties are required in your configuration.');
170
170
  process.exit(1);
171
171
  }
172
- options = config.options || {};
172
+ options = {...(config.options || {})};
173
173
  milkee = config.milkee || {};
174
174
  milkeeOptions = config.milkee.options || {};
175
175
  execCommandParts = ['coffee'];
@@ -259,24 +259,32 @@
259
259
  return;
260
260
  }
261
261
  }
262
- optionsForPlugins = {...options};
263
262
  delete options.join;
264
263
  if (milkeeOptions.refresh) {
265
264
  targetDir = path.join(CWD, config.output);
266
- if (!fs.existsSync(targetDir)) {
267
- consola.info("Refresh skipped.");
268
- } else {
269
- consola.info("Executing: Refresh");
270
- items = fs.readdirSync(targetDir);
271
- for (i = 0, len = items.length; i < len; i++) {
272
- item = items[i];
273
- itemPath = path.join(targetDir, item);
274
- fs.rmSync(itemPath, {
275
- recursive: true,
265
+ if (fs.existsSync(targetDir)) {
266
+ stat = fs.statSync(targetDir);
267
+ if (stat.isDirectory()) {
268
+ consola.info("Executing: Refresh");
269
+ items = fs.readdirSync(targetDir);
270
+ for (i = 0, len = items.length; i < len; i++) {
271
+ item = items[i];
272
+ itemPath = path.join(targetDir, item);
273
+ fs.rmSync(itemPath, {
274
+ recursive: true,
275
+ force: true
276
+ });
277
+ }
278
+ consola.success("Refreshed!");
279
+ } else {
280
+ consola.info("Executing: Refresh (Single File)");
281
+ fs.rmSync(targetDir, {
276
282
  force: true
277
283
  });
284
+ consola.success("Refreshed!");
278
285
  }
279
- consola.success("Refreshed!");
286
+ } else {
287
+ consola.info("Refresh skipped.");
280
288
  }
281
289
  }
282
290
  if (options.watch) {
@@ -310,7 +318,7 @@
310
318
  consola.warn("Compilation failed, plugins skipped.");
311
319
  } else {
312
320
  consola.success('Compilation successful (watch mode).');
313
- runPlugins(config, optionsForPlugins, '(watch mode)', '');
321
+ runPlugins(config, {...(config.options || {})}, '(watch mode)', '');
314
322
  }
315
323
  return lastError = null;
316
324
  }, 100);
@@ -341,7 +349,7 @@
341
349
  if (stderr && !error) {
342
350
  process.stderr.write(stderr);
343
351
  }
344
- return runPlugins(config, optionsForPlugins, stdout, stderr);
352
+ return runPlugins(config, {...(config.options || {})}, stdout, stderr);
345
353
  });
346
354
  }
347
355
  } catch (error1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "milkee",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "A simple CoffeeScript build tool with coffee.config.cjs",
5
5
  "main": "dist/main.js",
6
6
  "bin": {