trying to switch to npmlog cause it has levels and gauges oob 😋
This commit is contained in:
parent
586af11d9a
commit
ae00c2f1df
@ -1,4 +1,4 @@
|
||||
import chalk from 'chalk';
|
||||
import log from './log.js';
|
||||
import minimist from 'minimist';
|
||||
import { need } from './index.js';
|
||||
|
||||
@ -12,10 +12,10 @@ async function main () {
|
||||
const dontBuild = argv.db;
|
||||
const local = await need({ nodeRange, platform, arch,
|
||||
dontReadCache, dontDownload, dontBuild });
|
||||
console.log(local);
|
||||
log.info('Result', local);
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error(`> ${chalk.red('Error!')} ${error}`);
|
||||
log.error(error);
|
||||
process.exit(2);
|
||||
});
|
||||
|
||||
18
lib/index.js
18
lib/index.js
@ -3,9 +3,9 @@ import { abiToNodeRange, hostArch, // eslint-disable-line no-duplicate-imports
|
||||
hostPlatform, toFancyArch, toFancyPlatform } from './system.js';
|
||||
import { localPlace, remotePlace } from './places.js';
|
||||
import build from './build.js';
|
||||
import chalk from 'chalk';
|
||||
import { download } from './cloud.js';
|
||||
import { exists } from 'fs-promise';
|
||||
import log from './log.js';
|
||||
import patchesJson from '../patches/patches.json';
|
||||
import path from 'path';
|
||||
import semver from 'semver';
|
||||
@ -32,24 +32,24 @@ export async function need ({
|
||||
const name = path.basename(local);
|
||||
|
||||
if (dontReadCache) {
|
||||
console.log(`> ${chalk.yellow('Refusing to read cache')}`);
|
||||
log.info('Refusing to read cache');
|
||||
} else {
|
||||
console.log(`> ${chalk.yellow('Looking in cache')} ${name}`);
|
||||
log.info('Looking in cache', name);
|
||||
if (await exists(local)) return local;
|
||||
console.log(`> ${chalk.yellow('Not found in cache')}`);
|
||||
log.warn('Not found in cache');
|
||||
}
|
||||
if (dontDownload) {
|
||||
console.log(`> ${chalk.yellow('Refusing to download')}`);
|
||||
log.info('Refusing to download');
|
||||
} else {
|
||||
console.log(`> ${chalk.yellow('Downloading')} ${name}`);
|
||||
log.info('Downloading', name);
|
||||
const remote = remotePlace({ arch, nodeVersion, platform, version });
|
||||
if (await download(remote, local)) return local;
|
||||
console.log(`> ${chalk.yellow('Not found in GitHub releases')}`);
|
||||
log.warn('Not found in GitHub releases');
|
||||
}
|
||||
if (dontBuild) {
|
||||
console.log(`> ${chalk.yellow('Refusing to build from source')}`);
|
||||
log.info('Refusing to build from source');
|
||||
} else {
|
||||
console.log(`> ${chalk.yellow('Building from source')} ${name}`);
|
||||
log.info('Building from source');
|
||||
await build({ copyDest: local, nodeVersion, targetArch: arch });
|
||||
return local;
|
||||
}
|
||||
|
||||
6
lib/log.js
Normal file
6
lib/log.js
Normal file
@ -0,0 +1,6 @@
|
||||
import log from 'npmlog';
|
||||
|
||||
log.heading = 'pkg-cache';
|
||||
log.prefixStyle = { fg: 'cyan' };
|
||||
|
||||
export default log;
|
||||
@ -1,7 +1,7 @@
|
||||
import { hostPlatform, targetArchs } from './system.js';
|
||||
import { localPlace, remotePlace } from './places.js';
|
||||
import build from './build.js';
|
||||
import chalk from 'chalk';
|
||||
import log from './log.js';
|
||||
import patchesJson from '../patches/patches.json';
|
||||
import { upload } from './cloud.js';
|
||||
import { version } from '../package.json';
|
||||
@ -17,9 +17,9 @@ export async function main () {
|
||||
for (const targetArch of targetArchs) {
|
||||
if (isBrokenBuild(nodeVersion, targetArch)) continue;
|
||||
const local = localPlace({ arch: targetArch, nodeVersion, platform: hostPlatform, version });
|
||||
console.log(`> ${chalk.yellow('Building')} ${nodeVersion}-${targetArch}`);
|
||||
log.info('Building', `${nodeVersion}-${targetArch}`);
|
||||
await build({ copyDest: local, nodeVersion, targetArch });
|
||||
console.log(`> ${chalk.yellow('Uploading')} ${local}`);
|
||||
log.info('Uploading', local);
|
||||
const remote = remotePlace({ arch: targetArch, nodeVersion, platform: hostPlatform, version });
|
||||
await upload(local, remote);
|
||||
}
|
||||
@ -28,7 +28,7 @@ export async function main () {
|
||||
|
||||
if (!module.parent) {
|
||||
main().catch((error) => {
|
||||
console.error(`> ${chalk.red('Error!')} ${error}`);
|
||||
log.error(error);
|
||||
process.exit(2);
|
||||
});
|
||||
}
|
||||
|
||||
@ -12,11 +12,11 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "1.1.3",
|
||||
"child-process-promise": "2.0.3",
|
||||
"expand-template": "1.0.2",
|
||||
"fs-promise": "0.5.0",
|
||||
"minimist": "1.2.0",
|
||||
"npmlog": "4.0.0",
|
||||
"request": "2.74.0",
|
||||
"semver": "5.3.0",
|
||||
"unique-temp-dir": "1.0.0"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user