milkee 0.0.4 → 0.0.6
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/main.js +56 -16
- package/package.json +1 -1
- package/temp/coffee.config.js +10 -8
package/dist/main.js
CHANGED
@@ -41,7 +41,7 @@
|
|
41
41
|
};
|
42
42
|
|
43
43
|
compile = function() {
|
44
|
-
var command, commandParts, config, error,
|
44
|
+
var command, commandParts, compilerProcess, config, error, i, item, itemPath, items, len, options, otherOptionStrings, targetDir;
|
45
45
|
if (!fs.existsSync(CONFIG_PATH)) {
|
46
46
|
consola.error(`\`${CONFIG_FILE}\` not found in this directory: ${CWD}`);
|
47
47
|
consola.info('Please run `milkee --setup` to create a configuration file.');
|
@@ -64,39 +64,79 @@
|
|
64
64
|
}
|
65
65
|
delete options.join;
|
66
66
|
otherOptionStrings = [];
|
67
|
-
|
68
|
-
|
69
|
-
if (
|
70
|
-
|
71
|
-
} else
|
72
|
-
|
67
|
+
if (options.refresh) {
|
68
|
+
targetDir = path.join(CWD, config.output);
|
69
|
+
if (!fs.existsSync(targetDir)) {
|
70
|
+
consola.info("Refresh skipped.");
|
71
|
+
} else {
|
72
|
+
items = fs.readdirSync(targetDir);
|
73
|
+
for (i = 0, len = items.length; i < len; i++) {
|
74
|
+
item = items[i];
|
75
|
+
itemPath = path.join(targetDir, item);
|
76
|
+
fs.rmSync(itemPath, {
|
77
|
+
recursive: true,
|
78
|
+
force: true
|
79
|
+
});
|
80
|
+
}
|
81
|
+
consola.success("Refreshed!");
|
73
82
|
}
|
74
83
|
}
|
84
|
+
if (options.bare) {
|
85
|
+
otherOptionStrings.push("--bare");
|
86
|
+
}
|
87
|
+
if (options.map) {
|
88
|
+
otherOptionStrings.push('--map');
|
89
|
+
}
|
90
|
+
if (options.inlineMap) {
|
91
|
+
otherOptionStrings.push('--inline-map');
|
92
|
+
}
|
93
|
+
if (options.noHeader) {
|
94
|
+
otherOptionStrings.push('--no-header');
|
95
|
+
}
|
96
|
+
if (options.transpile) {
|
97
|
+
otherOptionStrings.push('--transpile');
|
98
|
+
}
|
99
|
+
if (options.literate) {
|
100
|
+
otherOptionStrings.push('--literate');
|
101
|
+
}
|
102
|
+
if (options.watch) {
|
103
|
+
otherOptionStrings.push('--watch');
|
104
|
+
}
|
75
105
|
if (otherOptionStrings.length > 0) {
|
76
106
|
commandParts.push(otherOptionStrings.join(' '));
|
77
107
|
}
|
78
108
|
commandParts.push('--compile');
|
79
109
|
commandParts.push(`\"${config.entry}\"`);
|
80
110
|
command = commandParts.filter(Boolean).join(' ');
|
81
|
-
|
111
|
+
if (options.watch) {
|
112
|
+
consola.start(`Watching for changes in \`${config.entry}\`...`);
|
113
|
+
} else {
|
114
|
+
consola.start(`Compiling from \`${config.entry}\` to \`${config.output}\`...`);
|
115
|
+
}
|
82
116
|
consola.info(`Executing: ${command}`);
|
83
|
-
|
84
|
-
if (
|
85
|
-
|
86
|
-
|
87
|
-
|
117
|
+
compilerProcess = exec(command, function(error, stdout, stderr) {
|
118
|
+
if (!options.watch) {
|
119
|
+
if (error) {
|
120
|
+
consola.error('Compilation failed:', error);
|
121
|
+
if (stderr) {
|
122
|
+
process.stderr.write(stderr);
|
123
|
+
}
|
124
|
+
process.exit(1);
|
125
|
+
return;
|
88
126
|
}
|
89
|
-
process.exit(1);
|
90
|
-
return;
|
91
127
|
}
|
92
128
|
consola.success('Compilation completed successfully!');
|
93
129
|
if (stdout) {
|
94
130
|
process.stdout.write(stdout);
|
95
131
|
}
|
96
|
-
if (stderr) {
|
132
|
+
if (stderr && !error) {
|
97
133
|
return process.stderr.write(stderr);
|
98
134
|
}
|
99
135
|
});
|
136
|
+
if (options.watch) {
|
137
|
+
compilerProcess.stdout.pipe(process.stdout);
|
138
|
+
return compilerProcess.stderr.pipe(process.stderr);
|
139
|
+
}
|
100
140
|
} catch (error1) {
|
101
141
|
error = error1;
|
102
142
|
consola.error('Failed to load or execute configuration:', error);
|
package/package.json
CHANGED
package/temp/coffee.config.js
CHANGED
@@ -10,14 +10,16 @@ module.exports = {
|
|
10
10
|
|
11
11
|
// (Optional) Additional options for the CoffeeScript compiler.
|
12
12
|
// See `coffee --help` for all available options.
|
13
|
+
// Web: https://coffeescript.org/annotated-source/command.html
|
13
14
|
options: {
|
14
|
-
//
|
15
|
+
// The following options are supported:
|
16
|
+
// bare: false,
|
15
17
|
// join: false,
|
16
|
-
|
17
|
-
//
|
18
|
-
//
|
19
|
-
|
20
|
-
//
|
21
|
-
//
|
22
|
-
}
|
18
|
+
// map: false,
|
19
|
+
// inlineMap: false,
|
20
|
+
// noHeader: false,
|
21
|
+
// transpile: false,
|
22
|
+
// literate: false,
|
23
|
+
// watch: false,
|
24
|
+
},
|
23
25
|
};
|