@@ -98,6 +98,25 @@ module.exports = Octokit;
98
98
99
99
"use strict";
100
100
101
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
102
+ if (k2 === undefined) k2 = k;
103
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
104
+ }) : (function(o, m, k, k2) {
105
+ if (k2 === undefined) k2 = k;
106
+ o[k2] = m[k];
107
+ }));
108
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
109
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
110
+ }) : function(o, v) {
111
+ o["default"] = v;
112
+ });
113
+ var __importStar = (this && this.__importStar) || function (mod) {
114
+ if (mod && mod.__esModule) return mod;
115
+ var result = {};
116
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
117
+ __setModuleDefault(result, mod);
118
+ return result;
119
+ };
101
120
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
102
121
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
103
122
return new (P || (P = Promise))(function (resolve, reject) {
@@ -108,11 +127,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
108
127
});
109
128
};
110
129
Object.defineProperty(exports, "__esModule", { value: true });
111
- const childProcess = __webpack_require__(129);
112
- const path = __webpack_require__(622);
130
+ exports.findInPath = exports.which = exports.mkdirP = exports.rmRF = exports.mv = exports.cp = void 0;
131
+ const assert_1 = __webpack_require__(357);
132
+ const childProcess = __importStar(__webpack_require__(129));
133
+ const path = __importStar(__webpack_require__(622));
113
134
const util_1 = __webpack_require__(669);
114
- const ioUtil = __webpack_require__(672);
135
+ const ioUtil = __importStar( __webpack_require__(672) );
115
136
const exec = util_1.promisify(childProcess.exec);
137
+ const execFile = util_1.promisify(childProcess.execFile);
116
138
/**
117
139
* Copies a file or folder.
118
140
* Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
@@ -123,14 +145,14 @@ const exec = util_1.promisify(childProcess.exec);
123
145
*/
124
146
function cp(source, dest, options = {}) {
125
147
return __awaiter(this, void 0, void 0, function* () {
126
- const { force, recursive } = readCopyOptions(options);
148
+ const { force, recursive, copySourceDirectory } = readCopyOptions(options);
127
149
const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
128
150
// Dest is an existing file, but not forcing
129
151
if (destStat && destStat.isFile() && !force) {
130
152
return;
131
153
}
132
154
// If dest is an existing directory, should copy inside.
133
- const newDest = destStat && destStat.isDirectory()
155
+ const newDest = destStat && destStat.isDirectory() && copySourceDirectory
134
156
? path.join(dest, path.basename(source))
135
157
: dest;
136
158
if (!(yield ioUtil.exists(source))) {
@@ -195,12 +217,22 @@ function rmRF(inputPath) {
195
217
if (ioUtil.IS_WINDOWS) {
196
218
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
197
219
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
220
+ // Check for invalid characters
221
+ // https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
222
+ if (/[*"<>|]/.test(inputPath)) {
223
+ throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');
224
+ }
198
225
try {
226
+ const cmdPath = ioUtil.getCmdPath();
199
227
if (yield ioUtil.isDirectory(inputPath, true)) {
200
- yield exec(`rd /s /q "${inputPath}"`);
228
+ yield exec(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, {
229
+ env: { inputPath }
230
+ });
201
231
}
202
232
else {
203
- yield exec(`del /f /a "${inputPath}"`);
233
+ yield exec(`${cmdPath} /s /c "del /f /a "%inputPath%""`, {
234
+ env: { inputPath }
235
+ });
204
236
}
205
237
}
206
238
catch (err) {
@@ -233,7 +265,7 @@ function rmRF(inputPath) {
233
265
return;
234
266
}
235
267
if (isDir) {
236
- yield exec (`rm -rf " ${inputPath}"` );
268
+ yield execFile (`rm`, [` -rf`, ` ${inputPath}`] );
237
269
}
238
270
else {
239
271
yield ioUtil.unlink(inputPath);
@@ -251,7 +283,8 @@ exports.rmRF = rmRF;
251
283
*/
252
284
function mkdirP(fsPath) {
253
285
return __awaiter(this, void 0, void 0, function* () {
254
- yield ioUtil.mkdirP(fsPath);
286
+ assert_1.ok(fsPath, 'a path argument must be provided');
287
+ yield ioUtil.mkdir(fsPath, { recursive: true });
255
288
});
256
289
}
257
290
exports.mkdirP = mkdirP;
@@ -279,62 +312,80 @@ function which(tool, check) {
279
312
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);
280
313
}
281
314
}
315
+ return result;
282
316
}
283
- try {
284
- // build the list of extensions to try
285
- const extensions = [];
286
- if (ioUtil.IS_WINDOWS && process.env.PATHEXT) {
287
- for (const extension of process.env.PATHEXT.split(path.delimiter)) {
288
- if (extension) {
289
- extensions.push(extension);
290
- }
291
- }
292
- }
293
- // if it's rooted, return it if exists. otherwise return empty.
294
- if (ioUtil.isRooted(tool)) {
295
- const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
296
- if (filePath) {
297
- return filePath;
317
+ const matches = yield findInPath(tool);
318
+ if (matches && matches.length > 0) {
319
+ return matches[0];
320
+ }
321
+ return '';
322
+ });
323
+ }
324
+ exports.which = which;
325
+ /**
326
+ * Returns a list of all occurrences of the given tool on the system path.
327
+ *
328
+ * @returns Promise<string[]> the paths of the tool
329
+ */
330
+ function findInPath(tool) {
331
+ return __awaiter(this, void 0, void 0, function* () {
332
+ if (!tool) {
333
+ throw new Error("parameter 'tool' is required");
334
+ }
335
+ // build the list of extensions to try
336
+ const extensions = [];
337
+ if (ioUtil.IS_WINDOWS && process.env['PATHEXT']) {
338
+ for (const extension of process.env['PATHEXT'].split(path.delimiter)) {
339
+ if (extension) {
340
+ extensions.push(extension);
298
341
}
299
- return '';
300
342
}
301
- // if any path separators, return empty
302
- if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) {
303
- return '';
304
- }
305
- // build the list of directories
306
- //
307
- // Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
308
- // it feels like we should not do this. Checking the current directory seems like more of a use
309
- // case of a shell, and the which() function exposed by the toolkit should strive for consistency
310
- // across platforms.
311
- const directories = [];
312
- if (process.env.PATH) {
313
- for (const p of process.env.PATH.split(path.delimiter)) {
314
- if (p) {
315
- directories.push(p);
316
- }
317
- }
343
+ }
344
+ // if it's rooted, return it if exists. otherwise return empty.
345
+ if (ioUtil.isRooted(tool)) {
346
+ const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
347
+ if (filePath) {
348
+ return [filePath];
318
349
}
319
- // return the first match
320
- for (const directory of directories) {
321
- const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions);
322
- if (filePath) {
323
- return filePath;
350
+ return [];
351
+ }
352
+ // if any path separators, return empty
353
+ if (tool.includes(path.sep)) {
354
+ return [];
355
+ }
356
+ // build the list of directories
357
+ //
358
+ // Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
359
+ // it feels like we should not do this. Checking the current directory seems like more of a use
360
+ // case of a shell, and the which() function exposed by the toolkit should strive for consistency
361
+ // across platforms.
362
+ const directories = [];
363
+ if (process.env.PATH) {
364
+ for (const p of process.env.PATH.split(path.delimiter)) {
365
+ if (p) {
366
+ directories.push(p);
324
367
}
325
368
}
326
- return '';
327
369
}
328
- catch (err) {
329
- throw new Error(`which failed with message ${err.message}`);
370
+ // find all matches
371
+ const matches = [];
372
+ for (const directory of directories) {
373
+ const filePath = yield ioUtil.tryGetExecutablePath(path.join(directory, tool), extensions);
374
+ if (filePath) {
375
+ matches.push(filePath);
376
+ }
330
377
}
378
+ return matches;
331
379
});
332
380
}
333
- exports.which = which ;
381
+ exports.findInPath = findInPath ;
334
382
function readCopyOptions(options) {
335
383
const force = options.force == null ? true : options.force;
336
384
const recursive = Boolean(options.recursive);
337
- return { force, recursive };
385
+ const copySourceDirectory = options.copySourceDirectory == null
386
+ ? true
387
+ : Boolean(options.copySourceDirectory);
388
+ return { force, recursive, copySourceDirectory };
338
389
}
339
390
function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
340
391
return __awaiter(this, void 0, void 0, function* () {
@@ -16397,6 +16448,25 @@ module.exports = require("util");
16397
16448
16398
16449
"use strict";
16399
16450
16451
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16452
+ if (k2 === undefined) k2 = k;
16453
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
16454
+ }) : (function(o, m, k, k2) {
16455
+ if (k2 === undefined) k2 = k;
16456
+ o[k2] = m[k];
16457
+ }));
16458
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16459
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16460
+ }) : function(o, v) {
16461
+ o["default"] = v;
16462
+ });
16463
+ var __importStar = (this && this.__importStar) || function (mod) {
16464
+ if (mod && mod.__esModule) return mod;
16465
+ var result = {};
16466
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
16467
+ __setModuleDefault(result, mod);
16468
+ return result;
16469
+ };
16400
16470
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16401
16471
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16402
16472
return new (P || (P = Promise))(function (resolve, reject) {
@@ -16408,9 +16478,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
16408
16478
};
16409
16479
var _a;
16410
16480
Object.defineProperty(exports, "__esModule", { value: true });
16411
- const assert_1 = __webpack_require__(357) ;
16412
- const fs = __webpack_require__(747);
16413
- const path = __webpack_require__(622);
16481
+ exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rename = exports.readlink = exports.readdir = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0 ;
16482
+ const fs = __importStar( __webpack_require__(747) );
16483
+ const path = __importStar( __webpack_require__(622) );
16414
16484
_a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
16415
16485
exports.IS_WINDOWS = process.platform === 'win32';
16416
16486
function exists(fsPath) {
@@ -16451,49 +16521,6 @@ function isRooted(p) {
16451
16521
return p.startsWith('/');
16452
16522
}
16453
16523
exports.isRooted = isRooted;
16454
- /**
16455
- * Recursively create a directory at `fsPath`.
16456
- *
16457
- * This implementation is optimistic, meaning it attempts to create the full
16458
- * path first, and backs up the path stack from there.
16459
- *
16460
- * @param fsPath The path to create
16461
- * @param maxDepth The maximum recursion depth
16462
- * @param depth The current recursion depth
16463
- */
16464
- function mkdirP(fsPath, maxDepth = 1000, depth = 1) {
16465
- return __awaiter(this, void 0, void 0, function* () {
16466
- assert_1.ok(fsPath, 'a path argument must be provided');
16467
- fsPath = path.resolve(fsPath);
16468
- if (depth >= maxDepth)
16469
- return exports.mkdir(fsPath);
16470
- try {
16471
- yield exports.mkdir(fsPath);
16472
- return;
16473
- }
16474
- catch (err) {
16475
- switch (err.code) {
16476
- case 'ENOENT': {
16477
- yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1);
16478
- yield exports.mkdir(fsPath);
16479
- return;
16480
- }
16481
- default: {
16482
- let stats;
16483
- try {
16484
- stats = yield exports.stat(fsPath);
16485
- }
16486
- catch (err2) {
16487
- throw err;
16488
- }
16489
- if (!stats.isDirectory())
16490
- throw err;
16491
- }
16492
- }
16493
- }
16494
- });
16495
- }
16496
- exports.mkdirP = mkdirP;
16497
16524
/**
16498
16525
* Best effort attempt to determine whether a file exists and is executable.
16499
16526
* @param filePath file path to check
@@ -16590,6 +16617,12 @@ function isUnixExecutable(stats) {
16590
16617
((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
16591
16618
((stats.mode & 64) > 0 && stats.uid === process.getuid()));
16592
16619
}
16620
+ // Get the path of cmd.exe in windows
16621
+ function getCmdPath() {
16622
+ var _a;
16623
+ return (_a = process.env['COMSPEC']) !== null && _a !== void 0 ? _a : `cmd.exe`;
16624
+ }
16625
+ exports.getCmdPath = getCmdPath;
16593
16626
//# sourceMappingURL=io-util.js.map
16594
16627
16595
16628
/***/ }),
0 commit comments