milkee 2.0.0-dev.1 → 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 (3) hide show
  1. package/README.md +22 -1
  2. package/dist/main.js +24 -16
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -98,6 +98,8 @@ These options are passed directly to the `coffee` compiler.
98
98
  | `literate` | `boolean` | `false` | treat stdio as literate style coffeescript |
99
99
  | `watch` | `boolean` | `false` | watch scripts for changes and rerun commands |
100
100
 
101
+ [CoffeeScript - command.coffee](https://coffeescript.org/annotated-source/command.html)
102
+
101
103
  ##### `milkee.options` (Milkee Specific Options)
102
104
 
103
105
  These options control Milkee's behavior.
@@ -107,7 +109,26 @@ These options control Milkee's behavior.
107
109
  | `refresh` | `boolean` | `false` | Before compiling, reset the output directory. |
108
110
  | `confirm` | `boolean` | `false` | Before compiling, prompt "Do you want to Continue?". |
109
111
 
110
- [CoffeeScript - command.coffee](https://coffeescript.org/annotated-source/command.html)
112
+ ##### `milkee.plugins` (Milkee Specific Plugins)
113
+
114
+ You can extend Milkee's functionality by using plugins. Plugins are simple functions that run after each successful compilation, giving you access to the compiled files and configuration.
115
+
116
+ Example:
117
+
118
+ ```js
119
+ const myPlugin = require('./plugins/my-plugin.js');
120
+
121
+ module.exports = {
122
+ // ...
123
+ milkee: {
124
+ plugins: [
125
+ // This call returns the PluginExecutor
126
+ myPlugin({ option: 'value' }),
127
+ // ...
128
+ ]
129
+ }
130
+ }
131
+ ```
111
132
 
112
133
  ### Compile
113
134
 
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-dev.1",
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": {
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "homepage": "https://github.com/otoneko1102/coffeescript-milkee#readme",
34
34
  "dependencies": {
35
- "@milkee/d": "^0.1.0",
35
+ "@milkee/d": "^0.2.0",
36
36
  "consola": "^3.4.2",
37
37
  "yargs": "^18.0.0"
38
38
  },