@@ -8034,6 +8034,25 @@ class ExecState extends events.EventEmitter {
80348034
80358035"use strict";
80368036
8037+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8038+ if (k2 === undefined) k2 = k;
8039+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8040+ }) : (function(o, m, k, k2) {
8041+ if (k2 === undefined) k2 = k;
8042+ o[k2] = m[k];
8043+ }));
8044+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
8045+ Object.defineProperty(o, "default", { enumerable: true, value: v });
8046+ }) : function(o, v) {
8047+ o["default"] = v;
8048+ });
8049+ var __importStar = (this && this.__importStar) || function (mod) {
8050+ if (mod && mod.__esModule) return mod;
8051+ var result = {};
8052+ if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
8053+ __setModuleDefault(result, mod);
8054+ return result;
8055+ };
80378056var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
80388057 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
80398058 return new (P || (P = Promise))(function (resolve, reject) {
@@ -8045,11 +8064,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
80458064};
80468065var _a;
80478066Object.defineProperty(exports, "__esModule", ({ value: true }));
8048- const assert_1 = __nccwpck_require__(9491);
8049- const fs = __nccwpck_require__(7147);
8050- const path = __nccwpck_require__(1017);
8051- _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;
8067+ exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.READONLY = exports.UV_FS_O_EXLOCK = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rm = exports.rename = exports.readlink = exports.readdir = exports.open = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0;
8068+ const fs = __importStar(__nccwpck_require__(7147));
8069+ const path = __importStar(__nccwpck_require__(1017));
8070+ _a = fs.promises
8071+ // export const {open} = 'fs'
8072+ , exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.open = _a.open, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rm = _a.rm, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
8073+ // export const {open} = 'fs'
80528074exports.IS_WINDOWS = process.platform === 'win32';
8075+ // See https://github.com/nodejs/node/blob/d0153aee367422d0858105abec186da4dff0a0c5/deps/uv/include/uv/win.h#L691
8076+ exports.UV_FS_O_EXLOCK = 0x10000000;
8077+ exports.READONLY = fs.constants.O_RDONLY;
80538078function exists(fsPath) {
80548079 return __awaiter(this, void 0, void 0, function* () {
80558080 try {
@@ -8088,49 +8113,6 @@ function isRooted(p) {
80888113 return p.startsWith('/');
80898114}
80908115exports.isRooted = isRooted;
8091- /**
8092- * Recursively create a directory at `fsPath`.
8093- *
8094- * This implementation is optimistic, meaning it attempts to create the full
8095- * path first, and backs up the path stack from there.
8096- *
8097- * @param fsPath The path to create
8098- * @param maxDepth The maximum recursion depth
8099- * @param depth The current recursion depth
8100- */
8101- function mkdirP(fsPath, maxDepth = 1000, depth = 1) {
8102- return __awaiter(this, void 0, void 0, function* () {
8103- assert_1.ok(fsPath, 'a path argument must be provided');
8104- fsPath = path.resolve(fsPath);
8105- if (depth >= maxDepth)
8106- return exports.mkdir(fsPath);
8107- try {
8108- yield exports.mkdir(fsPath);
8109- return;
8110- }
8111- catch (err) {
8112- switch (err.code) {
8113- case 'ENOENT': {
8114- yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1);
8115- yield exports.mkdir(fsPath);
8116- return;
8117- }
8118- default: {
8119- let stats;
8120- try {
8121- stats = yield exports.stat(fsPath);
8122- }
8123- catch (err2) {
8124- throw err;
8125- }
8126- if (!stats.isDirectory())
8127- throw err;
8128- }
8129- }
8130- }
8131- });
8132- }
8133- exports.mkdirP = mkdirP;
81348116/**
81358117 * Best effort attempt to determine whether a file exists and is executable.
81368118 * @param filePath file path to check
@@ -8227,6 +8209,12 @@ function isUnixExecutable(stats) {
82278209 ((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
82288210 ((stats.mode & 64) > 0 && stats.uid === process.getuid()));
82298211}
8212+ // Get the path of cmd.exe in windows
8213+ function getCmdPath() {
8214+ var _a;
8215+ return (_a = process.env['COMSPEC']) !== null && _a !== void 0 ? _a : `cmd.exe`;
8216+ }
8217+ exports.getCmdPath = getCmdPath;
82308218//# sourceMappingURL=io-util.js.map
82318219
82328220/***/ }),
@@ -8236,6 +8224,25 @@ function isUnixExecutable(stats) {
82368224
82378225"use strict";
82388226
8227+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8228+ if (k2 === undefined) k2 = k;
8229+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8230+ }) : (function(o, m, k, k2) {
8231+ if (k2 === undefined) k2 = k;
8232+ o[k2] = m[k];
8233+ }));
8234+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
8235+ Object.defineProperty(o, "default", { enumerable: true, value: v });
8236+ }) : function(o, v) {
8237+ o["default"] = v;
8238+ });
8239+ var __importStar = (this && this.__importStar) || function (mod) {
8240+ if (mod && mod.__esModule) return mod;
8241+ var result = {};
8242+ if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
8243+ __setModuleDefault(result, mod);
8244+ return result;
8245+ };
82398246var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
82408247 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
82418248 return new (P || (P = Promise))(function (resolve, reject) {
@@ -8246,11 +8253,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
82468253 });
82478254};
82488255Object.defineProperty(exports, "__esModule", ({ value: true }));
8249- const childProcess = __nccwpck_require__(2081);
8250- const path = __nccwpck_require__(1017);
8251- const util_1 = __nccwpck_require__(3837);
8252- const ioUtil = __nccwpck_require__(1962);
8253- const exec = util_1.promisify(childProcess.exec);
8256+ exports.findInPath = exports.which = exports.mkdirP = exports.rmRF = exports.mv = exports.cp = void 0;
8257+ const assert_1 = __nccwpck_require__(9491);
8258+ const path = __importStar(__nccwpck_require__(1017));
8259+ const ioUtil = __importStar(__nccwpck_require__(1962));
82548260/**
82558261 * Copies a file or folder.
82568262 * Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
@@ -8261,14 +8267,14 @@ const exec = util_1.promisify(childProcess.exec);
82618267 */
82628268function cp(source, dest, options = {}) {
82638269 return __awaiter(this, void 0, void 0, function* () {
8264- const { force, recursive } = readCopyOptions(options);
8270+ const { force, recursive, copySourceDirectory } = readCopyOptions(options);
82658271 const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
82668272 // Dest is an existing file, but not forcing
82678273 if (destStat && destStat.isFile() && !force) {
82688274 return;
82698275 }
82708276 // If dest is an existing directory, should copy inside.
8271- const newDest = destStat && destStat.isDirectory()
8277+ const newDest = destStat && destStat.isDirectory() && copySourceDirectory
82728278 ? path.join(dest, path.basename(source))
82738279 : dest;
82748280 if (!(yield ioUtil.exists(source))) {
@@ -8331,51 +8337,23 @@ exports.mv = mv;
83318337function rmRF(inputPath) {
83328338 return __awaiter(this, void 0, void 0, function* () {
83338339 if (ioUtil.IS_WINDOWS) {
8334- // Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
8335- // program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
8336- try {
8337- if (yield ioUtil.isDirectory(inputPath, true)) {
8338- yield exec(`rd /s /q "${inputPath}"`);
8339- }
8340- else {
8341- yield exec(`del /f /a "${inputPath}"`);
8342- }
8343- }
8344- catch (err) {
8345- // if you try to delete a file that doesn't exist, desired result is achieved
8346- // other errors are valid
8347- if (err.code !== 'ENOENT')
8348- throw err;
8349- }
8350- // Shelling out fails to remove a symlink folder with missing source, this unlink catches that
8351- try {
8352- yield ioUtil.unlink(inputPath);
8353- }
8354- catch (err) {
8355- // if you try to delete a file that doesn't exist, desired result is achieved
8356- // other errors are valid
8357- if (err.code !== 'ENOENT')
8358- throw err;
8340+ // Check for invalid characters
8341+ // https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
8342+ if (/[*"<>|]/.test(inputPath)) {
8343+ throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');
83598344 }
83608345 }
8361- else {
8362- let isDir = false;
8363- try {
8364- isDir = yield ioUtil.isDirectory(inputPath);
8365- }
8366- catch (err) {
8367- // if you try to delete a file that doesn't exist, desired result is achieved
8368- // other errors are valid
8369- if (err.code !== 'ENOENT')
8370- throw err;
8371- return;
8372- }
8373- if (isDir) {
8374- yield exec(`rm -rf "${inputPath}"`);
8375- }
8376- else {
8377- yield ioUtil.unlink(inputPath);
8378- }
8346+ try {
8347+ // note if path does not exist, error is silent
8348+ yield ioUtil.rm(inputPath, {
8349+ force: true,
8350+ maxRetries: 3,
8351+ recursive: true,
8352+ retryDelay: 300
8353+ });
8354+ }
8355+ catch (err) {
8356+ throw new Error(`File was unable to be removed ${err}`);
83798357 }
83808358 });
83818359}
@@ -8389,7 +8367,8 @@ exports.rmRF = rmRF;
83898367 */
83908368function mkdirP(fsPath) {
83918369 return __awaiter(this, void 0, void 0, function* () {
8392- yield ioUtil.mkdirP(fsPath);
8370+ assert_1.ok(fsPath, 'a path argument must be provided');
8371+ yield ioUtil.mkdir(fsPath, { recursive: true });
83938372 });
83948373}
83958374exports.mkdirP = mkdirP;
@@ -8417,62 +8396,80 @@ function which(tool, check) {
84178396 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.`);
84188397 }
84198398 }
8399+ return result;
84208400 }
8421- try {
8422- // build the list of extensions to try
8423- const extensions = [];
8424- if (ioUtil.IS_WINDOWS && process.env.PATHEXT) {
8425- for (const extension of process.env.PATHEXT.split(path.delimiter)) {
8426- if (extension) {
8427- extensions.push(extension);
8428- }
8429- }
8430- }
8431- // if it's rooted, return it if exists. otherwise return empty.
8432- if (ioUtil.isRooted(tool)) {
8433- const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
8434- if (filePath) {
8435- return filePath;
8401+ const matches = yield findInPath(tool);
8402+ if (matches && matches.length > 0) {
8403+ return matches[0];
8404+ }
8405+ return '';
8406+ });
8407+ }
8408+ exports.which = which;
8409+ /**
8410+ * Returns a list of all occurrences of the given tool on the system path.
8411+ *
8412+ * @returns Promise<string[]> the paths of the tool
8413+ */
8414+ function findInPath(tool) {
8415+ return __awaiter(this, void 0, void 0, function* () {
8416+ if (!tool) {
8417+ throw new Error("parameter 'tool' is required");
8418+ }
8419+ // build the list of extensions to try
8420+ const extensions = [];
8421+ if (ioUtil.IS_WINDOWS && process.env['PATHEXT']) {
8422+ for (const extension of process.env['PATHEXT'].split(path.delimiter)) {
8423+ if (extension) {
8424+ extensions.push(extension);
84368425 }
8437- return '';
84388426 }
8439- // if any path separators, return empty
8440- if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) {
8441- return '';
8442- }
8443- // build the list of directories
8444- //
8445- // Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
8446- // it feels like we should not do this. Checking the current directory seems like more of a use
8447- // case of a shell, and the which() function exposed by the toolkit should strive for consistency
8448- // across platforms.
8449- const directories = [];
8450- if (process.env.PATH) {
8451- for (const p of process.env.PATH.split(path.delimiter)) {
8452- if (p) {
8453- directories.push(p);
8454- }
8455- }
8427+ }
8428+ // if it's rooted, return it if exists. otherwise return empty.
8429+ if (ioUtil.isRooted(tool)) {
8430+ const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
8431+ if (filePath) {
8432+ return [filePath];
84568433 }
8457- // return the first match
8458- for (const directory of directories) {
8459- const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions);
8460- if (filePath) {
8461- return filePath;
8434+ return [];
8435+ }
8436+ // if any path separators, return empty
8437+ if (tool.includes(path.sep)) {
8438+ return [];
8439+ }
8440+ // build the list of directories
8441+ //
8442+ // Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
8443+ // it feels like we should not do this. Checking the current directory seems like more of a use
8444+ // case of a shell, and the which() function exposed by the toolkit should strive for consistency
8445+ // across platforms.
8446+ const directories = [];
8447+ if (process.env.PATH) {
8448+ for (const p of process.env.PATH.split(path.delimiter)) {
8449+ if (p) {
8450+ directories.push(p);
84628451 }
84638452 }
8464- return '';
84658453 }
8466- catch (err) {
8467- throw new Error(`which failed with message ${err.message}`);
8454+ // find all matches
8455+ const matches = [];
8456+ for (const directory of directories) {
8457+ const filePath = yield ioUtil.tryGetExecutablePath(path.join(directory, tool), extensions);
8458+ if (filePath) {
8459+ matches.push(filePath);
8460+ }
84688461 }
8462+ return matches;
84698463 });
84708464}
8471- exports.which = which ;
8465+ exports.findInPath = findInPath ;
84728466function readCopyOptions(options) {
84738467 const force = options.force == null ? true : options.force;
84748468 const recursive = Boolean(options.recursive);
8475- return { force, recursive };
8469+ const copySourceDirectory = options.copySourceDirectory == null
8470+ ? true
8471+ : Boolean(options.copySourceDirectory);
8472+ return { force, recursive, copySourceDirectory };
84768473}
84778474function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
84788475 return __awaiter(this, void 0, void 0, function* () {
0 commit comments