copies compiled binaries to ~/.pkg-cache
This commit is contained in:
parent
5a2ab2f401
commit
38ac05233e
12
lib/build.js
12
lib/build.js
@ -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
12
lib/copy-file.js
Normal 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);
|
||||
});
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user