Skip to content

Commit af9dd51

Browse files
authored
Merge pull request #27 from per1234/dependabot/npm_and_yarn/actions/io-1.1.0
build(deps-dev): bump @actions/io from 1.0.0 to 1.1.0
2 parents 5c93a74 + 09c4469 commit af9dd51

File tree

3 files changed

+84
-53
lines changed

3 files changed

+84
-53
lines changed

dist/index.js

Lines changed: 80 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,18 +1308,26 @@ class ExecState extends events.EventEmitter {
13081308
"use strict";
13091309

13101310
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1311+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13111312
return new (P || (P = Promise))(function (resolve, reject) {
13121313
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13131314
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1314-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
1315+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13151316
step((generator = generator.apply(thisArg, _arguments || [])).next());
13161317
});
13171318
};
1319+
var __importStar = (this && this.__importStar) || function (mod) {
1320+
if (mod && mod.__esModule) return mod;
1321+
var result = {};
1322+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
1323+
result["default"] = mod;
1324+
return result;
1325+
};
13181326
var _a;
13191327
Object.defineProperty(exports, "__esModule", ({ value: true }));
13201328
const assert_1 = __nccwpck_require__(357);
1321-
const fs = __nccwpck_require__(747);
1322-
const path = __nccwpck_require__(622);
1329+
const fs = __importStar(__nccwpck_require__(747));
1330+
const path = __importStar(__nccwpck_require__(622));
13231331
_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;
13241332
exports.IS_WINDOWS = process.platform === 'win32';
13251333
function exists(fsPath) {
@@ -1509,18 +1517,26 @@ function isUnixExecutable(stats) {
15091517
"use strict";
15101518

15111519
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1520+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15121521
return new (P || (P = Promise))(function (resolve, reject) {
15131522
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15141523
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1515-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
1524+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
15161525
step((generator = generator.apply(thisArg, _arguments || [])).next());
15171526
});
15181527
};
1528+
var __importStar = (this && this.__importStar) || function (mod) {
1529+
if (mod && mod.__esModule) return mod;
1530+
var result = {};
1531+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
1532+
result["default"] = mod;
1533+
return result;
1534+
};
15191535
Object.defineProperty(exports, "__esModule", ({ value: true }));
1520-
const childProcess = __nccwpck_require__(129);
1521-
const path = __nccwpck_require__(622);
1536+
const childProcess = __importStar(__nccwpck_require__(129));
1537+
const path = __importStar(__nccwpck_require__(622));
15221538
const util_1 = __nccwpck_require__(669);
1523-
const ioUtil = __nccwpck_require__(962);
1539+
const ioUtil = __importStar(__nccwpck_require__(962));
15241540
const exec = util_1.promisify(childProcess.exec);
15251541
/**
15261542
* Copies a file or folder.
@@ -1688,58 +1704,73 @@ function which(tool, check) {
16881704
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.`);
16891705
}
16901706
}
1707+
return result;
16911708
}
1692-
try {
1693-
// build the list of extensions to try
1694-
const extensions = [];
1695-
if (ioUtil.IS_WINDOWS && process.env.PATHEXT) {
1696-
for (const extension of process.env.PATHEXT.split(path.delimiter)) {
1697-
if (extension) {
1698-
extensions.push(extension);
1699-
}
1700-
}
1701-
}
1702-
// if it's rooted, return it if exists. otherwise return empty.
1703-
if (ioUtil.isRooted(tool)) {
1704-
const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
1705-
if (filePath) {
1706-
return filePath;
1709+
const matches = yield findInPath(tool);
1710+
if (matches && matches.length > 0) {
1711+
return matches[0];
1712+
}
1713+
return '';
1714+
});
1715+
}
1716+
exports.which = which;
1717+
/**
1718+
* Returns a list of all occurrences of the given tool on the system path.
1719+
*
1720+
* @returns Promise<string[]> the paths of the tool
1721+
*/
1722+
function findInPath(tool) {
1723+
return __awaiter(this, void 0, void 0, function* () {
1724+
if (!tool) {
1725+
throw new Error("parameter 'tool' is required");
1726+
}
1727+
// build the list of extensions to try
1728+
const extensions = [];
1729+
if (ioUtil.IS_WINDOWS && process.env['PATHEXT']) {
1730+
for (const extension of process.env['PATHEXT'].split(path.delimiter)) {
1731+
if (extension) {
1732+
extensions.push(extension);
17071733
}
1708-
return '';
17091734
}
1710-
// if any path separators, return empty
1711-
if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) {
1712-
return '';
1713-
}
1714-
// build the list of directories
1715-
//
1716-
// Note, technically "where" checks the current directory on Windows. From a task lib perspective,
1717-
// it feels like we should not do this. Checking the current directory seems like more of a use
1718-
// case of a shell, and the which() function exposed by the task lib should strive for consistency
1719-
// across platforms.
1720-
const directories = [];
1721-
if (process.env.PATH) {
1722-
for (const p of process.env.PATH.split(path.delimiter)) {
1723-
if (p) {
1724-
directories.push(p);
1725-
}
1726-
}
1735+
}
1736+
// if it's rooted, return it if exists. otherwise return empty.
1737+
if (ioUtil.isRooted(tool)) {
1738+
const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
1739+
if (filePath) {
1740+
return [filePath];
17271741
}
1728-
// return the first match
1729-
for (const directory of directories) {
1730-
const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions);
1731-
if (filePath) {
1732-
return filePath;
1742+
return [];
1743+
}
1744+
// if any path separators, return empty
1745+
if (tool.includes(path.sep)) {
1746+
return [];
1747+
}
1748+
// build the list of directories
1749+
//
1750+
// Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
1751+
// it feels like we should not do this. Checking the current directory seems like more of a use
1752+
// case of a shell, and the which() function exposed by the toolkit should strive for consistency
1753+
// across platforms.
1754+
const directories = [];
1755+
if (process.env.PATH) {
1756+
for (const p of process.env.PATH.split(path.delimiter)) {
1757+
if (p) {
1758+
directories.push(p);
17331759
}
17341760
}
1735-
return '';
17361761
}
1737-
catch (err) {
1738-
throw new Error(`which failed with message ${err.message}`);
1762+
// find all matches
1763+
const matches = [];
1764+
for (const directory of directories) {
1765+
const filePath = yield ioUtil.tryGetExecutablePath(path.join(directory, tool), extensions);
1766+
if (filePath) {
1767+
matches.push(filePath);
1768+
}
17391769
}
1770+
return matches;
17401771
});
17411772
}
1742-
exports.which = which;
1773+
exports.findInPath = findInPath;
17431774
function readCopyOptions(options) {
17441775
const force = options.force == null ? true : options.force;
17451776
const recursive = Boolean(options.recursive);

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"typed-rest-client": "^1.8.4"
2828
},
2929
"devDependencies": {
30-
"@actions/io": "^1.0.0",
30+
"@actions/io": "^1.1.0",
3131
"@types/jest": "^26.0.23",
3232
"@types/node": "^12.0.4",
3333
"@types/semver": "^7.3.5",

0 commit comments

Comments
 (0)