Build: Added node 8 support.
This commit is contained in:
parent
4306b3563a
commit
f8072a8004
@ -17,7 +17,7 @@ const log_1 = require("../log");
|
||||
const dependencies = local_1.getDependencies(null, (name) => {
|
||||
return !path_1.isEthers(name);
|
||||
});
|
||||
console.log(log_1.colorify.bold(`Hoisting ${dependencies.length} dependencies into root package...`));
|
||||
console.log(log_1.colorify.bold(`Hoisting ${Object.keys(dependencies).length} dependencies into root package...`));
|
||||
local_1.updateJson(path_1.dirs.rootPackageJsonPath, { dependencies });
|
||||
});
|
||||
})().catch((error) => {
|
||||
|
@ -17,6 +17,7 @@ const path_1 = require("path");
|
||||
const local_1 = require("../local");
|
||||
const log_1 = require("../log");
|
||||
const path_2 = require("../path");
|
||||
const utils_1 = require("../utils");
|
||||
function link(existing, path) {
|
||||
try {
|
||||
const current = fs_1.default.readlinkSync(path);
|
||||
@ -33,7 +34,7 @@ function link(existing, path) {
|
||||
}
|
||||
// Link
|
||||
const dir = path_1.dirname(path);
|
||||
fs_1.default.mkdirSync(dir, { recursive: true });
|
||||
utils_1.mkdir(dir);
|
||||
fs_1.default.symlinkSync(existing, path);
|
||||
}
|
||||
(function () {
|
||||
@ -46,7 +47,7 @@ function link(existing, path) {
|
||||
link(path_2.getPackagePath(name), path_1.resolve(path_2.dirs.root, "node_modules", name));
|
||||
// e.g. /packages/abi/node_modules => /.package_node_modules/abi/
|
||||
const nodeModules = path_1.resolve(nodeModulesBase, path_2.getDirname(name));
|
||||
fs_1.default.mkdirSync(nodeModules, { recursive: true });
|
||||
utils_1.mkdir(nodeModules);
|
||||
link(nodeModules, path_1.resolve(path_2.getPackagePath(name), "node_modules"));
|
||||
});
|
||||
path_2.packages.forEach((name) => {
|
||||
|
1
misc/admin/lib/utils.d.ts
vendored
1
misc/admin/lib/utils.d.ts
vendored
@ -6,3 +6,4 @@ export declare function atomicWrite(path: string, value: string | Uint8Array): v
|
||||
export declare function loadJson(path: string): any;
|
||||
export declare function saveJson(filename: string, data: any, sort?: boolean): any;
|
||||
export declare function resolveProperties(props: Record<string, Promise<any>>): Promise<Record<string, any>>;
|
||||
export declare function mkdir(path: string): void;
|
||||
|
@ -83,3 +83,22 @@ function resolveProperties(props) {
|
||||
});
|
||||
}
|
||||
exports.resolveProperties = resolveProperties;
|
||||
// Node 8 does not support recursive mkdir... Remove this in v6.
|
||||
function mkdir(path) {
|
||||
let bail = 0;
|
||||
const dirs = [];
|
||||
while (path !== "/") {
|
||||
if (bail++ > 50) {
|
||||
throw new Error("something bad happened...");
|
||||
}
|
||||
if (fs_1.default.existsSync(path)) {
|
||||
break;
|
||||
}
|
||||
dirs.push(path);
|
||||
path = path_1.dirname(path);
|
||||
}
|
||||
while (dirs.length) {
|
||||
fs_1.default.mkdirSync(dirs.pop());
|
||||
}
|
||||
}
|
||||
exports.mkdir = mkdir;
|
||||
|
@ -8,7 +8,7 @@ import { colorify } from "../log";
|
||||
return !isEthers(name);
|
||||
});
|
||||
|
||||
console.log(colorify.bold(`Hoisting ${ dependencies.length } dependencies into root package...`));
|
||||
console.log(colorify.bold(`Hoisting ${ Object.keys(dependencies).length } dependencies into root package...`));
|
||||
|
||||
updateJson(dirs.rootPackageJsonPath, { dependencies });
|
||||
})().catch((error) => {
|
||||
|
@ -4,6 +4,7 @@ import { dirname, resolve } from "path";
|
||||
import { getDependencies } from "../local";
|
||||
import { colorify } from "../log";
|
||||
import { dirs, getDirname, getPackagePath, packages } from "../path";
|
||||
import { mkdir } from "../utils";
|
||||
|
||||
function link(existing: string, path: string): void {
|
||||
try {
|
||||
@ -19,7 +20,7 @@ function link(existing: string, path: string): void {
|
||||
|
||||
// Link
|
||||
const dir = dirname(path);
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
mkdir(dir);
|
||||
fs.symlinkSync(existing, path);
|
||||
}
|
||||
|
||||
@ -36,7 +37,7 @@ function link(existing: string, path: string): void {
|
||||
|
||||
// e.g. /packages/abi/node_modules => /.package_node_modules/abi/
|
||||
const nodeModules = resolve(nodeModulesBase, getDirname(name));
|
||||
fs.mkdirSync(nodeModules, { recursive: true });
|
||||
mkdir(nodeModules);
|
||||
link(nodeModules, resolve(getPackagePath(name), "node_modules"));
|
||||
});
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import fs from "fs";
|
||||
import { resolve } from "path";
|
||||
import { dirname, resolve } from "path";
|
||||
|
||||
import { createHash } from "crypto";
|
||||
|
||||
@ -66,3 +66,20 @@ export async function resolveProperties(props: Record<string, Promise<any>>): Pr
|
||||
return accum;
|
||||
}, <Record<string, any>>{});
|
||||
}
|
||||
|
||||
// Node 8 does not support recursive mkdir... Remove this in v6.
|
||||
export function mkdir(path: string): void {
|
||||
let bail = 0;
|
||||
const dirs = [ ];
|
||||
while (path !== "/") {
|
||||
if (bail++ > 50) { throw new Error("something bad happened..."); }
|
||||
|
||||
if (fs.existsSync(path)) { break; }
|
||||
dirs.push(path);
|
||||
path = dirname(path);
|
||||
}
|
||||
|
||||
while (dirs.length) {
|
||||
fs.mkdirSync(dirs.pop());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user