Skip to content

Commit

Permalink
add some debug log messages (#1039)
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Sep 11, 2020
1 parent 33a434a commit d771829
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
3 changes: 3 additions & 0 deletions snowpack/src/commands/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import rollupPluginNodeResolve from '@rollup/plugin-node-resolve';
import rollupPluginNodePolyfills from 'rollup-plugin-node-polyfills';
import {init as initESModuleLexer} from 'es-module-lexer';
import findUp from 'find-up';
import util from 'util';
import fs from 'fs';
import * as colors from 'kleur/colors';
import mkdirp from 'mkdirp';
Expand Down Expand Up @@ -398,13 +399,15 @@ ${colors.dim(
};
if (Object.keys(installEntrypoints).length > 0) {
try {
logger.debug(`running installer with options: ${util.format(inputOptions)}`);
const packageBundle = await rollup(inputOptions);
logger.debug(
`installing npm packages:\n ${Object.keys(installEntrypoints).join('\n ')}`,
);
if (isFatalWarningFound) {
throw new Error(FAILED_INSTALL_MESSAGE);
}
logger.debug(`writing install results to disk`);
await packageBundle.write(outputOptions);
} catch (_err) {
const err: RollupError = _err;
Expand Down
25 changes: 17 additions & 8 deletions snowpack/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as colors from 'kleur/colors';
import path from 'path';
import util from 'util';
import yargs from 'yargs-parser';
import {addCommand, rmCommand} from './commands/add-rm';
import {command as buildCommand} from './commands/build';
Expand Down Expand Up @@ -46,6 +47,13 @@ export async function cli(args: string[]) {
const cliFlags = yargs(args, {
array: ['install', 'env', 'exclude', 'externalPackage'],
}) as CLIFlags;

if (cliFlags.verbose) {
logger.level = 'debug';
}
if (cliFlags.quiet) {
logger.level = 'silent';
}
if (cliFlags.help) {
printHelp();
process.exit(0);
Expand All @@ -58,7 +66,6 @@ export async function cli(args: string[]) {
logger.info(colors.yellow('! clearing cache...'));
await clearCache();
}

// Load the current package manifest
let pkgManifest: any;
try {
Expand All @@ -68,7 +75,8 @@ export async function cli(args: string[]) {
process.exit(1);
}

const cmd = cliFlags['_'][2];
const cmd = cliFlags['_'][2] || 'install';
logger.debug(`run command: ${cmd}`);

// Set this early -- before config loading -- so that plugins see it.
if (cmd === 'build') {
Expand All @@ -78,17 +86,18 @@ export async function cli(args: string[]) {
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
}

const config = loadAndValidateConfig(cliFlags, pkgManifest);
logger.debug(`config loaded: ${util.format(config)}`);
const lockfile = await readLockfile(cwd);
logger.debug(`lockfile ${lockfile ? 'loaded.' : 'not loaded'}`);
const commandOptions = {
cwd,
config: loadAndValidateConfig(cliFlags, pkgManifest),
lockfile: await readLockfile(cwd),
config,
lockfile,
pkgManifest,
logger,
};

if (cliFlags.verbose) logger.level = 'debug';
if (cliFlags.quiet) logger.level = 'silent';

if (cmd === 'add') {
await addCommand(cliFlags['_'][3], commandOptions);
return process.exit(0);
Expand All @@ -111,7 +120,7 @@ export async function cli(args: string[]) {
await devCommand(commandOptions);
return process.exit(0);
}
if (cmd === 'install' || !cmd) {
if (cmd === 'install') {
await installCommand(commandOptions);
return process.exit(0);
}
Expand Down

1 comment on commit d771829

@vercel
Copy link

@vercel vercel bot commented on d771829 Sep 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.