mushroom-cli 1.2.0-alpha.7 → 1.2.0-alpha.7.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.
- package/README.md +1 -1
- package/common.js +10 -0
- package/package.json +3 -2
package/README.md
CHANGED
package/common.js
CHANGED
|
@@ -192,11 +192,15 @@ function processSetCommand(command, variables) {
|
|
|
192
192
|
case "Trim":
|
|
193
193
|
trimCommand(command.variable, variables, command.input);
|
|
194
194
|
break;
|
|
195
|
+
case "Replace":
|
|
196
|
+
replaceCommand(command.variable, variables, command.input, command.replacement, command.pattern, command.mode);
|
|
197
|
+
break;
|
|
195
198
|
default:
|
|
196
199
|
throw new Error(`Unknown set-command: ${command["function"]}`);
|
|
197
200
|
}
|
|
198
201
|
}
|
|
199
202
|
|
|
203
|
+
//#region set-commands
|
|
200
204
|
function processSetGuidCommand(variable, variables) {
|
|
201
205
|
variables[variable] = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
|
|
202
206
|
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
@@ -216,6 +220,12 @@ function trimCommand(variable, variables, input) {
|
|
|
216
220
|
variables[variable] = (variables[input] || "").trim();
|
|
217
221
|
}
|
|
218
222
|
|
|
223
|
+
function replaceCommand(variable, variables, input, replacement, pattern, mode) {
|
|
224
|
+
var regex = new RegExp(pattern, mode);
|
|
225
|
+
variables[variable] = (variables[input] || "").replace(regex, replacement === undefined || replacement === null ? "" : replacement);
|
|
226
|
+
}
|
|
227
|
+
//#endregion
|
|
228
|
+
|
|
219
229
|
function processRenameCommand(command, basePath, variables) {
|
|
220
230
|
const input = replaceVariables(command.input, variables);
|
|
221
231
|
const output = replaceVariables(command.output, variables);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mushroom-cli",
|
|
3
|
-
"version": "1.2.0-alpha.7",
|
|
3
|
+
"version": "1.2.0-alpha.7.1",
|
|
4
4
|
"description": "Mushroom CLI",
|
|
5
5
|
"main": "mr.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
},
|
|
17
17
|
"author": "suco2007",
|
|
18
18
|
"license": "ISC",
|
|
19
|
+
"dependencies-comments": "node-fetch: 2.x; open: 8.x",
|
|
19
20
|
"dependencies": {
|
|
20
21
|
"jsdom": "^22.1.0",
|
|
21
22
|
"json5": "^2.2.3",
|
|
22
23
|
"node-fetch": "^2.6.11",
|
|
23
|
-
"open": "^
|
|
24
|
+
"open": "^8.4.2",
|
|
24
25
|
"readline-sync": "^1.4.10",
|
|
25
26
|
"targz": "^1.0.1"
|
|
26
27
|
}
|