copies compiled binaries to ~/.pkg-cache

This commit is contained in:
igorklopov 2016-08-10 13:27:28 +03:00
parent 5a2ab2f401
commit 38ac05233e
3 changed files with 25 additions and 5 deletions

View File

@ -1,6 +1,7 @@
import { platform, targets } from './system.js';
import chipo from 'child-process-promise';
import chalk from 'chalk';
import copyFile from './copy-file.js';
import { localPath } from './places.js';
import mkdirp from 'mkdirp-promise';
import patchesJson from '../patches/patches.json';
@ -56,14 +57,17 @@ async function main () {
{ stdio: 'inherit', cwd: nodePath });
}
let outputBinary;
let output;
if (windows) {
outputBinary = await compileOnWindows(target);
output = await compileOnWindows(target);
} else {
outputBinary = await compileOnUnix(target);
output = await compileOnUnix(target);
}
// TODO place to ~/.pkg-cache
const dest = localPath({ version,
nodeVersion, platform, arch: target });
await mkdirp(path.dirname(dest));
await copyFile(output, dest);
}
}
}

12
lib/copy-file.js Normal file
View File

@ -0,0 +1,12 @@
import fs from 'fs';
export default function copyFile (src, dest) {
return new Promise((resolve, reject) => {
const rs = fs.createReadStream(src);
rs.on('error', reject);
const ws = fs.createWriteStream(dest);
ws.on('error', reject);
ws.on('finish', resolve);
rs.pipe(ws);
});
}

View File

@ -1,4 +1,6 @@
import expandTemplate from 'expand-template';
import os from 'os';
import path from 'path';
const expand = expandTemplate();
const binaries = {
@ -7,5 +9,7 @@ const binaries = {
};
export function localPath (opts) {
return expand(binaries.localPath, opts);
const p = binaries.localPath;
const atHome = p.replace('~', os.homedir());
return expand(path.resolve(atHome), opts);
}