зеркало из https://github.com/microsoft/node-pty.git
Copy conpty.dll and openconsole.exe depending on arch in postinstall
This commit is contained in:
Родитель
ddcd0b09ad
Коммит
43921691ee
|
@ -9,7 +9,10 @@ module.exports = {
|
|||
"project": "src/tsconfig.json",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"ignorePatterns": "**/typings/*.d.ts",
|
||||
"ignorePatterns": [
|
||||
"**/typings/*.d.ts",
|
||||
"scripts/**/*"
|
||||
],
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
|
|
|
@ -10,7 +10,8 @@ const ptyProcess = pty.spawn(shell, [], {
|
|||
rows: 26,
|
||||
cwd: isWindows ? process.env.USERPROFILE : process.env.HOME,
|
||||
env: Object.assign({ TEST: "Environment vars work" }, process.env),
|
||||
useConpty: true
|
||||
useConpty: true,
|
||||
useConptyDll: true
|
||||
});
|
||||
|
||||
ptyProcess.onData(data => process.stdout.write(data));
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
//@ts-check
|
||||
|
||||
var RELEASE_DIR = path.join(__dirname, '..', 'build', 'Release');
|
||||
var BUILD_FILES = [
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
|
||||
const RELEASE_DIR = path.join(__dirname, '../build/Release');
|
||||
const BUILD_FILES = [
|
||||
path.join(RELEASE_DIR, 'conpty.node'),
|
||||
path.join(RELEASE_DIR, 'conpty.pdb'),
|
||||
path.join(RELEASE_DIR, 'conpty_console_list.node'),
|
||||
|
@ -15,14 +18,18 @@ var BUILD_FILES = [
|
|||
path.join(RELEASE_DIR, 'winpty.dll'),
|
||||
path.join(RELEASE_DIR, 'winpty.pdb')
|
||||
];
|
||||
const CONPTY_DIR = path.join(__dirname, '../third_party/conpty');
|
||||
const CONPTY_SUPPORTED_ARCH = ['x64', 'arm64'];
|
||||
|
||||
cleanFolderRecursive = function(folder) {
|
||||
console.log('\x1b[32m> Cleaning release folder...\x1b[0m');
|
||||
|
||||
function cleanFolderRecursive(folder) {
|
||||
var files = [];
|
||||
if( fs.existsSync(folder) ) {
|
||||
if (fs.existsSync(folder)) {
|
||||
files = fs.readdirSync(folder);
|
||||
files.forEach(function(file,index) {
|
||||
var curPath = path.join(folder, file);
|
||||
if(fs.lstatSync(curPath).isDirectory()) { // recurse
|
||||
if (fs.lstatSync(curPath).isDirectory()) { // recurse
|
||||
cleanFolderRecursive(curPath);
|
||||
fs.rmdirSync(curPath);
|
||||
} else if (BUILD_FILES.indexOf(curPath) < 0){ // delete file
|
||||
|
@ -36,7 +43,29 @@ try {
|
|||
cleanFolderRecursive(RELEASE_DIR);
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
//process.exit(1);
|
||||
} finally {
|
||||
process.exit(0);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`\x1b[32m> Moving conpty.dll...\x1b[0m`);
|
||||
if (os.platform() !== 'win32') {
|
||||
console.log(' SKIPPED (not Windows)');
|
||||
} else {
|
||||
const windowsArch = os.arch();
|
||||
if (!CONPTY_SUPPORTED_ARCH.includes(windowsArch)) {
|
||||
console.log(` SKIPPED (unsupported architecture ${windowsArch})`);
|
||||
} else {
|
||||
const versionFolder = fs.readdirSync(CONPTY_DIR)[0];
|
||||
console.log(` Found version ${versionFolder}`);
|
||||
const sourceFolder = path.join(CONPTY_DIR, versionFolder, `win10-${windowsArch}`);
|
||||
const destFolder = path.join(RELEASE_DIR, 'conpty');
|
||||
fs.mkdirSync(destFolder, { recursive: true });
|
||||
for (const file of ['conpty.dll', 'OpenConsole.exe']) {
|
||||
const sourceFile = path.join(sourceFolder, file);
|
||||
const destFile = path.join(destFolder, file);
|
||||
console.log(` Copying ${sourceFile} -> ${destFile}`);
|
||||
fs.copyFileSync(sourceFile, destFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
|
|
|
@ -177,8 +177,7 @@ HANDLE LoadConptyDll(const Napi::CallbackInfo& info,
|
|||
}
|
||||
std::wstring currentDirStr(currentDir);
|
||||
|
||||
// TODO: Support arm64
|
||||
std::wstring conptyDllPath = currentDirStr + L"\\third_party\\conpty\\1.19.240130002\\win10-x64\\conpty.dll";
|
||||
std::wstring conptyDllPath = currentDirStr + L"\\build\\Release\\conpty\\conpty.dll";
|
||||
if (!path_util::file_exists(conptyDllPath)) {
|
||||
throw errorWithCode(info, "Cannot find conpty.dll");
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче