mirror of
https://github.com/actions/setup-node.git
synced 2025-04-03 01:49:34 +08:00
Use custom 7zr
This commit is contained in:
parent
d7b6952411
commit
a78e5a55c8
BIN
externals/7zr.exe
vendored
Normal file
BIN
externals/7zr.exe
vendored
Normal file
Binary file not shown.
|
@ -168,8 +168,8 @@ function acquireNode(version) {
|
|||
//
|
||||
let extPath;
|
||||
if (osPlat == 'win32') {
|
||||
let _7zPath = path.join(__dirname, '7zr.exe');
|
||||
extPath = yield tc.extract7z(downloadPath);
|
||||
let _7zPath = path.join(__dirname, '..', 'externals', '7zr.exe');
|
||||
extPath = yield tc.extract7z(downloadPath, undefined, _7zPath);
|
||||
}
|
||||
else {
|
||||
extPath = yield tc.extractTar(downloadPath);
|
||||
|
|
10
node_modules/@actions/tool-cache/lib/tool-cache.d.ts
generated
vendored
10
node_modules/@actions/tool-cache/lib/tool-cache.d.ts
generated
vendored
|
@ -14,9 +14,17 @@ export declare function downloadTool(url: string): Promise<string>;
|
|||
*
|
||||
* @param file path to the .7z file
|
||||
* @param dest destination directory. Optional.
|
||||
* @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this
|
||||
* problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will
|
||||
* gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is
|
||||
* bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line
|
||||
* interface, it is smaller than the full command line interface, and it does support long paths. At the
|
||||
* time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website.
|
||||
* Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path
|
||||
* to 7zr.exe can be pass to this function.
|
||||
* @returns path to the destination directory
|
||||
*/
|
||||
export declare function extract7z(file: string, dest?: string): Promise<string>;
|
||||
export declare function extract7z(file: string, dest?: string, _7zPath?: string): Promise<string>;
|
||||
/**
|
||||
* Extract a tar
|
||||
*
|
||||
|
|
80
node_modules/@actions/tool-cache/lib/tool-cache.js
generated
vendored
80
node_modules/@actions/tool-cache/lib/tool-cache.js
generated
vendored
|
@ -114,41 +114,69 @@ exports.downloadTool = downloadTool;
|
|||
*
|
||||
* @param file path to the .7z file
|
||||
* @param dest destination directory. Optional.
|
||||
* @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this
|
||||
* problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will
|
||||
* gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is
|
||||
* bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line
|
||||
* interface, it is smaller than the full command line interface, and it does support long paths. At the
|
||||
* time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website.
|
||||
* Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path
|
||||
* to 7zr.exe can be pass to this function.
|
||||
* @returns path to the destination directory
|
||||
*/
|
||||
function extract7z(file, dest) {
|
||||
function extract7z(file, dest, _7zPath) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS');
|
||||
assert_1.ok(file, 'parameter "file" is required');
|
||||
dest = dest || (yield _createExtractFolder(dest));
|
||||
const originalCwd = process.cwd();
|
||||
process.chdir(dest);
|
||||
const escapedScript = path
|
||||
.join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1')
|
||||
.replace(/'/g, "''")
|
||||
.replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
|
||||
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
||||
const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
||||
const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`;
|
||||
const args = [
|
||||
'-NoLogo',
|
||||
'-Sta',
|
||||
'-NoProfile',
|
||||
'-NonInteractive',
|
||||
'-ExecutionPolicy',
|
||||
'Unrestricted',
|
||||
'-Command',
|
||||
command
|
||||
];
|
||||
const options = {
|
||||
silent: true
|
||||
};
|
||||
try {
|
||||
const powershellPath = yield io.which('powershell', true);
|
||||
yield exec_1.exec(`"${powershellPath}"`, args, options);
|
||||
if (_7zPath) {
|
||||
try {
|
||||
const args = [
|
||||
'x',
|
||||
'-bb1',
|
||||
'-bd',
|
||||
'-sccUTF-8',
|
||||
file
|
||||
];
|
||||
const options = {
|
||||
silent: true
|
||||
};
|
||||
yield exec_1.exec(`"${_7zPath}"`, args, options);
|
||||
}
|
||||
finally {
|
||||
process.chdir(originalCwd);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
process.chdir(originalCwd);
|
||||
else {
|
||||
const escapedScript = path
|
||||
.join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1')
|
||||
.replace(/'/g, "''")
|
||||
.replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
|
||||
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
||||
const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
||||
const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`;
|
||||
const args = [
|
||||
'-NoLogo',
|
||||
'-Sta',
|
||||
'-NoProfile',
|
||||
'-NonInteractive',
|
||||
'-ExecutionPolicy',
|
||||
'Unrestricted',
|
||||
'-Command',
|
||||
command
|
||||
];
|
||||
const options = {
|
||||
silent: true
|
||||
};
|
||||
try {
|
||||
const powershellPath = yield io.which('powershell', true);
|
||||
yield exec_1.exec(`"${powershellPath}"`, args, options);
|
||||
}
|
||||
finally {
|
||||
process.chdir(originalCwd);
|
||||
}
|
||||
}
|
||||
return dest;
|
||||
});
|
||||
|
|
2
node_modules/@actions/tool-cache/lib/tool-cache.js.map
generated
vendored
2
node_modules/@actions/tool-cache/lib/tool-cache.js.map
generated
vendored
File diff suppressed because one or more lines are too long
17
node_modules/@actions/tool-cache/package.json
generated
vendored
17
node_modules/@actions/tool-cache/package.json
generated
vendored
|
@ -1,6 +1,12 @@
|
|||
{
|
||||
"_from": "file:toolkit\\actions-tool-cache-1.0.0.tgz",
|
||||
"_id": "@actions/tool-cache@1.0.0",
|
||||
"_args": [
|
||||
[
|
||||
"@actions/tool-cache@file:toolkit\\actions-tool-cache-1.0.0.tgz",
|
||||
"C:\\Users\\damccorm\\Documents\\setup-node"
|
||||
]
|
||||
],
|
||||
"_from": "@actions/tool-cache@file:toolkit/actions-tool-cache-1.0.0.tgz",
|
||||
"_id": "@actions/tool-cache@file:toolkit/actions-tool-cache-1.0.0.tgz",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-hx8Z1ip11aZVA47uSCIB7Y9ec4Ty9zNPUyFyBsr0YI5vJ64TR/JoySbr0ck7l2EI0zqYAdef11Ynwz/qUkXVyg==",
|
||||
"_location": "/@actions/tool-cache",
|
||||
|
@ -19,14 +25,12 @@
|
|||
"_requiredBy": [
|
||||
"/"
|
||||
],
|
||||
"_resolved": "C:\\Users\\damccorm\\Documents\\setup-node\\toolkit\\actions-tool-cache-1.0.0.tgz",
|
||||
"_shasum": "8650345f81eafb208916ec718e75188978d58567",
|
||||
"_spec": "@actions/tool-cache@file:toolkit/actions-tool-cache-1.0.0.tgz",
|
||||
"_resolved": false,
|
||||
"_spec": "file:toolkit/actions-tool-cache-1.0.0.tgz",
|
||||
"_where": "C:\\Users\\damccorm\\Documents\\setup-node",
|
||||
"bugs": {
|
||||
"url": "https://github.com/actions/toolkit/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@actions/core": "^0.1.0",
|
||||
"@actions/exec": "^1.0.0",
|
||||
|
@ -35,7 +39,6 @@
|
|||
"typed-rest-client": "^1.4.0",
|
||||
"uuid": "^3.3.2"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Actions tool-cache lib",
|
||||
"devDependencies": {
|
||||
"@types/nock": "^10.0.3",
|
||||
|
|
|
@ -174,8 +174,8 @@ async function acquireNode(version: string): Promise<string> {
|
|||
//
|
||||
let extPath: string;
|
||||
if (osPlat == 'win32') {
|
||||
let _7zPath = path.join(__dirname, '7zr.exe');
|
||||
extPath = await tc.extract7z(downloadPath);
|
||||
let _7zPath = path.join(__dirname, '..', 'externals', '7zr.exe');
|
||||
extPath = await tc.extract7z(downloadPath, undefined, _7zPath);
|
||||
} else {
|
||||
extPath = await tc.extractTar(downloadPath);
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user