Skip to content

Commit 2086b35

Browse files
authored
Merge pull request #40 from arduino/dependabot/npm_and_yarn/actions/io-1.1.1
Bump @actions/io from 1.0.2 to 1.1.1
2 parents bb8ecd6 + 5079076 commit 2086b35

File tree

3 files changed

+135
-102
lines changed

3 files changed

+135
-102
lines changed

dist/index.js

+131-98
Original file line numberDiff line numberDiff line change
@@ -2337,6 +2337,25 @@ exports.checkBypass = checkBypass;
23372337

23382338
"use strict";
23392339

2340+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2341+
if (k2 === undefined) k2 = k;
2342+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
2343+
}) : (function(o, m, k, k2) {
2344+
if (k2 === undefined) k2 = k;
2345+
o[k2] = m[k];
2346+
}));
2347+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
2348+
Object.defineProperty(o, "default", { enumerable: true, value: v });
2349+
}) : function(o, v) {
2350+
o["default"] = v;
2351+
});
2352+
var __importStar = (this && this.__importStar) || function (mod) {
2353+
if (mod && mod.__esModule) return mod;
2354+
var result = {};
2355+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
2356+
__setModuleDefault(result, mod);
2357+
return result;
2358+
};
23402359
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
23412360
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23422361
return new (P || (P = Promise))(function (resolve, reject) {
@@ -2348,9 +2367,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
23482367
};
23492368
var _a;
23502369
Object.defineProperty(exports, "__esModule", ({ value: true }));
2351-
const assert_1 = __nccwpck_require__(9491);
2352-
const fs = __nccwpck_require__(7147);
2353-
const path = __nccwpck_require__(1017);
2370+
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;
2371+
const fs = __importStar(__nccwpck_require__(7147));
2372+
const path = __importStar(__nccwpck_require__(1017));
23542373
_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;
23552374
exports.IS_WINDOWS = process.platform === 'win32';
23562375
function exists(fsPath) {
@@ -2391,49 +2410,6 @@ function isRooted(p) {
23912410
return p.startsWith('/');
23922411
}
23932412
exports.isRooted = isRooted;
2394-
/**
2395-
* Recursively create a directory at `fsPath`.
2396-
*
2397-
* This implementation is optimistic, meaning it attempts to create the full
2398-
* path first, and backs up the path stack from there.
2399-
*
2400-
* @param fsPath The path to create
2401-
* @param maxDepth The maximum recursion depth
2402-
* @param depth The current recursion depth
2403-
*/
2404-
function mkdirP(fsPath, maxDepth = 1000, depth = 1) {
2405-
return __awaiter(this, void 0, void 0, function* () {
2406-
assert_1.ok(fsPath, 'a path argument must be provided');
2407-
fsPath = path.resolve(fsPath);
2408-
if (depth >= maxDepth)
2409-
return exports.mkdir(fsPath);
2410-
try {
2411-
yield exports.mkdir(fsPath);
2412-
return;
2413-
}
2414-
catch (err) {
2415-
switch (err.code) {
2416-
case 'ENOENT': {
2417-
yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1);
2418-
yield exports.mkdir(fsPath);
2419-
return;
2420-
}
2421-
default: {
2422-
let stats;
2423-
try {
2424-
stats = yield exports.stat(fsPath);
2425-
}
2426-
catch (err2) {
2427-
throw err;
2428-
}
2429-
if (!stats.isDirectory())
2430-
throw err;
2431-
}
2432-
}
2433-
}
2434-
});
2435-
}
2436-
exports.mkdirP = mkdirP;
24372413
/**
24382414
* Best effort attempt to determine whether a file exists and is executable.
24392415
* @param filePath file path to check
@@ -2530,6 +2506,12 @@ function isUnixExecutable(stats) {
25302506
((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
25312507
((stats.mode & 64) > 0 && stats.uid === process.getuid()));
25322508
}
2509+
// Get the path of cmd.exe in windows
2510+
function getCmdPath() {
2511+
var _a;
2512+
return (_a = process.env['COMSPEC']) !== null && _a !== void 0 ? _a : `cmd.exe`;
2513+
}
2514+
exports.getCmdPath = getCmdPath;
25332515
//# sourceMappingURL=io-util.js.map
25342516

25352517
/***/ }),
@@ -2539,6 +2521,25 @@ function isUnixExecutable(stats) {
25392521

25402522
"use strict";
25412523

2524+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2525+
if (k2 === undefined) k2 = k;
2526+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
2527+
}) : (function(o, m, k, k2) {
2528+
if (k2 === undefined) k2 = k;
2529+
o[k2] = m[k];
2530+
}));
2531+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
2532+
Object.defineProperty(o, "default", { enumerable: true, value: v });
2533+
}) : function(o, v) {
2534+
o["default"] = v;
2535+
});
2536+
var __importStar = (this && this.__importStar) || function (mod) {
2537+
if (mod && mod.__esModule) return mod;
2538+
var result = {};
2539+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
2540+
__setModuleDefault(result, mod);
2541+
return result;
2542+
};
25422543
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
25432544
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
25442545
return new (P || (P = Promise))(function (resolve, reject) {
@@ -2549,11 +2550,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
25492550
});
25502551
};
25512552
Object.defineProperty(exports, "__esModule", ({ value: true }));
2552-
const childProcess = __nccwpck_require__(2081);
2553-
const path = __nccwpck_require__(1017);
2553+
exports.findInPath = exports.which = exports.mkdirP = exports.rmRF = exports.mv = exports.cp = void 0;
2554+
const assert_1 = __nccwpck_require__(9491);
2555+
const childProcess = __importStar(__nccwpck_require__(2081));
2556+
const path = __importStar(__nccwpck_require__(1017));
25542557
const util_1 = __nccwpck_require__(3837);
2555-
const ioUtil = __nccwpck_require__(1962);
2558+
const ioUtil = __importStar(__nccwpck_require__(1962));
25562559
const exec = util_1.promisify(childProcess.exec);
2560+
const execFile = util_1.promisify(childProcess.execFile);
25572561
/**
25582562
* Copies a file or folder.
25592563
* Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
@@ -2564,14 +2568,14 @@ const exec = util_1.promisify(childProcess.exec);
25642568
*/
25652569
function cp(source, dest, options = {}) {
25662570
return __awaiter(this, void 0, void 0, function* () {
2567-
const { force, recursive } = readCopyOptions(options);
2571+
const { force, recursive, copySourceDirectory } = readCopyOptions(options);
25682572
const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
25692573
// Dest is an existing file, but not forcing
25702574
if (destStat && destStat.isFile() && !force) {
25712575
return;
25722576
}
25732577
// If dest is an existing directory, should copy inside.
2574-
const newDest = destStat && destStat.isDirectory()
2578+
const newDest = destStat && destStat.isDirectory() && copySourceDirectory
25752579
? path.join(dest, path.basename(source))
25762580
: dest;
25772581
if (!(yield ioUtil.exists(source))) {
@@ -2636,12 +2640,22 @@ function rmRF(inputPath) {
26362640
if (ioUtil.IS_WINDOWS) {
26372641
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
26382642
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
2643+
// Check for invalid characters
2644+
// https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
2645+
if (/[*"<>|]/.test(inputPath)) {
2646+
throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');
2647+
}
26392648
try {
2649+
const cmdPath = ioUtil.getCmdPath();
26402650
if (yield ioUtil.isDirectory(inputPath, true)) {
2641-
yield exec(`rd /s /q "${inputPath}"`);
2651+
yield exec(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, {
2652+
env: { inputPath }
2653+
});
26422654
}
26432655
else {
2644-
yield exec(`del /f /a "${inputPath}"`);
2656+
yield exec(`${cmdPath} /s /c "del /f /a "%inputPath%""`, {
2657+
env: { inputPath }
2658+
});
26452659
}
26462660
}
26472661
catch (err) {
@@ -2674,7 +2688,7 @@ function rmRF(inputPath) {
26742688
return;
26752689
}
26762690
if (isDir) {
2677-
yield exec(`rm -rf "${inputPath}"`);
2691+
yield execFile(`rm`, [`-rf`, `${inputPath}`]);
26782692
}
26792693
else {
26802694
yield ioUtil.unlink(inputPath);
@@ -2692,7 +2706,8 @@ exports.rmRF = rmRF;
26922706
*/
26932707
function mkdirP(fsPath) {
26942708
return __awaiter(this, void 0, void 0, function* () {
2695-
yield ioUtil.mkdirP(fsPath);
2709+
assert_1.ok(fsPath, 'a path argument must be provided');
2710+
yield ioUtil.mkdir(fsPath, { recursive: true });
26962711
});
26972712
}
26982713
exports.mkdirP = mkdirP;
@@ -2720,62 +2735,80 @@ function which(tool, check) {
27202735
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.`);
27212736
}
27222737
}
2738+
return result;
27232739
}
2724-
try {
2725-
// build the list of extensions to try
2726-
const extensions = [];
2727-
if (ioUtil.IS_WINDOWS && process.env.PATHEXT) {
2728-
for (const extension of process.env.PATHEXT.split(path.delimiter)) {
2729-
if (extension) {
2730-
extensions.push(extension);
2731-
}
2740+
const matches = yield findInPath(tool);
2741+
if (matches && matches.length > 0) {
2742+
return matches[0];
2743+
}
2744+
return '';
2745+
});
2746+
}
2747+
exports.which = which;
2748+
/**
2749+
* Returns a list of all occurrences of the given tool on the system path.
2750+
*
2751+
* @returns Promise<string[]> the paths of the tool
2752+
*/
2753+
function findInPath(tool) {
2754+
return __awaiter(this, void 0, void 0, function* () {
2755+
if (!tool) {
2756+
throw new Error("parameter 'tool' is required");
2757+
}
2758+
// build the list of extensions to try
2759+
const extensions = [];
2760+
if (ioUtil.IS_WINDOWS && process.env['PATHEXT']) {
2761+
for (const extension of process.env['PATHEXT'].split(path.delimiter)) {
2762+
if (extension) {
2763+
extensions.push(extension);
27322764
}
27332765
}
2734-
// if it's rooted, return it if exists. otherwise return empty.
2735-
if (ioUtil.isRooted(tool)) {
2736-
const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
2737-
if (filePath) {
2738-
return filePath;
2739-
}
2740-
return '';
2741-
}
2742-
// if any path separators, return empty
2743-
if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) {
2744-
return '';
2745-
}
2746-
// build the list of directories
2747-
//
2748-
// Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
2749-
// it feels like we should not do this. Checking the current directory seems like more of a use
2750-
// case of a shell, and the which() function exposed by the toolkit should strive for consistency
2751-
// across platforms.
2752-
const directories = [];
2753-
if (process.env.PATH) {
2754-
for (const p of process.env.PATH.split(path.delimiter)) {
2755-
if (p) {
2756-
directories.push(p);
2757-
}
2758-
}
2766+
}
2767+
// if it's rooted, return it if exists. otherwise return empty.
2768+
if (ioUtil.isRooted(tool)) {
2769+
const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
2770+
if (filePath) {
2771+
return [filePath];
27592772
}
2760-
// return the first match
2761-
for (const directory of directories) {
2762-
const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions);
2763-
if (filePath) {
2764-
return filePath;
2773+
return [];
2774+
}
2775+
// if any path separators, return empty
2776+
if (tool.includes(path.sep)) {
2777+
return [];
2778+
}
2779+
// build the list of directories
2780+
//
2781+
// Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
2782+
// it feels like we should not do this. Checking the current directory seems like more of a use
2783+
// case of a shell, and the which() function exposed by the toolkit should strive for consistency
2784+
// across platforms.
2785+
const directories = [];
2786+
if (process.env.PATH) {
2787+
for (const p of process.env.PATH.split(path.delimiter)) {
2788+
if (p) {
2789+
directories.push(p);
27652790
}
27662791
}
2767-
return '';
27682792
}
2769-
catch (err) {
2770-
throw new Error(`which failed with message ${err.message}`);
2793+
// find all matches
2794+
const matches = [];
2795+
for (const directory of directories) {
2796+
const filePath = yield ioUtil.tryGetExecutablePath(path.join(directory, tool), extensions);
2797+
if (filePath) {
2798+
matches.push(filePath);
2799+
}
27712800
}
2801+
return matches;
27722802
});
27732803
}
2774-
exports.which = which;
2804+
exports.findInPath = findInPath;
27752805
function readCopyOptions(options) {
27762806
const force = options.force == null ? true : options.force;
27772807
const recursive = Boolean(options.recursive);
2778-
return { force, recursive };
2808+
const copySourceDirectory = options.copySourceDirectory == null
2809+
? true
2810+
: Boolean(options.copySourceDirectory);
2811+
return { force, recursive, copySourceDirectory };
27792812
}
27802813
function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
27812814
return __awaiter(this, void 0, void 0, function* () {

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"semver": "^7.3.5"
3030
},
3131
"devDependencies": {
32-
"@actions/io": "^1.0.2",
32+
"@actions/io": "^1.1.1",
3333
"@types/jest": "^27.4.0",
3434
"@types/node": "^12.19.8",
3535
"@types/semver": "^7.3.9",

0 commit comments

Comments
 (0)