Partial import processing

This commit is contained in:
2020-06-15 16:03:01 -05:00
parent f29ecf5d5d
commit 5e6431d630
8 changed files with 104 additions and 11 deletions

View File

@@ -683,6 +683,48 @@ module.exports.getMissingDependencies = dependencies => {
});
};
module.exports.importSkylinks = (version, jsonArray) => {
return new Promise((resolve, reject) => {
const repertoryExec = _getRepertoryExec(version);
const processOptions = {
cwd: repertoryExec.working,
detached: true,
shell: false,
windowsHide: true,
};
const args = _getDefaultRepertoryArgs('Skynet');
args.push('-ij');
args.push(JSON.stringify(jsonArray));
let result = '';
const process = new spawn(repertoryExec.cmd, args, processOptions);
process.on('error', (err) => {
reject(err);
});
process.stdout.on('data', (d)=> {
result += d;
});
process.stderr.on('data', (d)=> {
result += d;
});
process.on('exit', code => {
if (code === 0) {
result = result.substr(result.indexOf('{'));
resolve(JSON.parse(result));
} else {
reject(new Error('Failed to import: ' + code + ':' + result));
}
});
process.unref();
});
};
//https://stackoverflow.com/questions/31645738/how-to-create-full-path-with-nodes-fs-mkdirsync
module.exports.mkDirByPathSync = (targetDir, { isRelativeToScript = false } = {}) => {
const sep = path.sep;