Skip to content

Commit 26d48e8

Browse files
authoredDec 12, 2022
Update @actions/io to 1.1.2 (#1029)
1 parent bf08527 commit 26d48e8

File tree

4 files changed

+19150
-3809
lines changed

4 files changed

+19150
-3809
lines changed
 

‎.licenses/npm/@actions/io.dep.yml

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

‎dist/index.js

+131-98
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,25 @@ module.exports = Octokit;
9898

9999
"use strict";
100100

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+
};
101120
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
102121
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
103122
return new (P || (P = Promise))(function (resolve, reject) {
@@ -108,11 +127,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
108127
});
109128
};
110129
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));
113134
const util_1 = __webpack_require__(669);
114-
const ioUtil = __webpack_require__(672);
135+
const ioUtil = __importStar(__webpack_require__(672));
115136
const exec = util_1.promisify(childProcess.exec);
137+
const execFile = util_1.promisify(childProcess.execFile);
116138
/**
117139
* Copies a file or folder.
118140
* 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);
123145
*/
124146
function cp(source, dest, options = {}) {
125147
return __awaiter(this, void 0, void 0, function* () {
126-
const { force, recursive } = readCopyOptions(options);
148+
const { force, recursive, copySourceDirectory } = readCopyOptions(options);
127149
const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
128150
// Dest is an existing file, but not forcing
129151
if (destStat && destStat.isFile() && !force) {
130152
return;
131153
}
132154
// If dest is an existing directory, should copy inside.
133-
const newDest = destStat && destStat.isDirectory()
155+
const newDest = destStat && destStat.isDirectory() && copySourceDirectory
134156
? path.join(dest, path.basename(source))
135157
: dest;
136158
if (!(yield ioUtil.exists(source))) {
@@ -195,12 +217,22 @@ function rmRF(inputPath) {
195217
if (ioUtil.IS_WINDOWS) {
196218
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
197219
// 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+
}
198225
try {
226+
const cmdPath = ioUtil.getCmdPath();
199227
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+
});
201231
}
202232
else {
203-
yield exec(`del /f /a "${inputPath}"`);
233+
yield exec(`${cmdPath} /s /c "del /f /a "%inputPath%""`, {
234+
env: { inputPath }
235+
});
204236
}
205237
}
206238
catch (err) {
@@ -233,7 +265,7 @@ function rmRF(inputPath) {
233265
return;
234266
}
235267
if (isDir) {
236-
yield exec(`rm -rf "${inputPath}"`);
268+
yield execFile(`rm`, [`-rf`, `${inputPath}`]);
237269
}
238270
else {
239271
yield ioUtil.unlink(inputPath);
@@ -251,7 +283,8 @@ exports.rmRF = rmRF;
251283
*/
252284
function mkdirP(fsPath) {
253285
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 });
255288
});
256289
}
257290
exports.mkdirP = mkdirP;
@@ -279,62 +312,80 @@ function which(tool, check) {
279312
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.`);
280313
}
281314
}
315+
return result;
282316
}
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);
298341
}
299-
return '';
300342
}
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];
318349
}
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);
324367
}
325368
}
326-
return '';
327369
}
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+
}
330377
}
378+
return matches;
331379
});
332380
}
333-
exports.which = which;
381+
exports.findInPath = findInPath;
334382
function readCopyOptions(options) {
335383
const force = options.force == null ? true : options.force;
336384
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 };
338389
}
339390
function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
340391
return __awaiter(this, void 0, void 0, function* () {
@@ -16397,6 +16448,25 @@ module.exports = require("util");
1639716448

1639816449
"use strict";
1639916450

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+
};
1640016470
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1640116471
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1640216472
return new (P || (P = Promise))(function (resolve, reject) {
@@ -16408,9 +16478,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
1640816478
};
1640916479
var _a;
1641016480
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));
1641416484
_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;
1641516485
exports.IS_WINDOWS = process.platform === 'win32';
1641616486
function exists(fsPath) {
@@ -16451,49 +16521,6 @@ function isRooted(p) {
1645116521
return p.startsWith('/');
1645216522
}
1645316523
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;
1649716524
/**
1649816525
* Best effort attempt to determine whether a file exists and is executable.
1649916526
* @param filePath file path to check
@@ -16590,6 +16617,12 @@ function isUnixExecutable(stats) {
1659016617
((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
1659116618
((stats.mode & 64) > 0 && stats.uid === process.getuid()));
1659216619
}
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;
1659316626
//# sourceMappingURL=io-util.js.map
1659416627

1659516628
/***/ }),

‎package-lock.json

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

‎package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,20 @@
3131
"@actions/core": "^1.10.0",
3232
"@actions/exec": "^1.0.1",
3333
"@actions/github": "^2.2.0",
34-
"@actions/io": "^1.0.1",
34+
"@actions/io": "^1.1.2",
3535
"@actions/tool-cache": "^1.1.2",
3636
"uuid": "^3.3.3"
3737
},
3838
"devDependencies": {
3939
"@types/jest": "^27.0.2",
4040
"@types/node": "^12.7.12",
4141
"@types/uuid": "^3.4.6",
42-
"@typescript-eslint/parser": "^5.1.0",
42+
"@typescript-eslint/eslint-plugin": "^5.45.0",
43+
"@typescript-eslint/parser": "^5.45.0",
4344
"@zeit/ncc": "^0.20.5",
4445
"eslint": "^7.32.0",
4546
"eslint-plugin-github": "^4.3.2",
46-
"eslint-plugin-jest": "^25.2.2",
47+
"eslint-plugin-jest": "^25.7.0",
4748
"jest": "^27.3.0",
4849
"jest-circus": "^27.3.0",
4950
"js-yaml": "^3.13.1",

0 commit comments

Comments
 (0)
Please sign in to comment.