Skip to content

Commit

Permalink
use node-logger instead of console
Browse files Browse the repository at this point in the history
  • Loading branch information
Quramy committed Jan 17, 2018
1 parent d20da16 commit 44ec036
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 21 deletions.
1 change: 1 addition & 0 deletions app/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@storybook/addons": "^3.4.0-alpha.4",
"@storybook/channel-postmessage": "^3.4.0-alpha.4",
"@storybook/core": "^3.4.0-alpha.4",
"@storybook/node-logger": "^3.4.0-alpha.4",
"@storybook/ui": "^3.4.0-alpha.4",
"airbnb-js-shims": "^1.1.1",
"angular2-template-loader": "^0.6.2",
Expand Down
7 changes: 3 additions & 4 deletions app/angular/src/server/angular-cli_config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const path = require('path');
const fs = require('fs');

const logger = console;
import path from 'path';
import fs from 'fs';
import { logger } from '@storybook/node-logger';

function isAngularCliInstalled() {
try {
Expand Down
4 changes: 1 addition & 3 deletions app/angular/src/server/babel_config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import fs from 'fs';
import path from 'path';
import JSON5 from 'json5';
import { logger } from '@storybook/node-logger';
import defaultConfig from './config/babel';

// avoid ESLint errors
const logger = console;

function removeReactHmre(presets) {
const index = presets.indexOf('react-hmre');
if (index > -1) {
Expand Down
8 changes: 3 additions & 5 deletions app/angular/src/server/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ import path from 'path';
import fs from 'fs';
import chalk from 'chalk';
import shelljs from 'shelljs';
import { logger } from '@storybook/node-logger';
import packageJson from '../../package.json';
import getBaseConfig from './config/webpack.config.prod';
import loadConfig from './config';
import { parseList, getEnvConfig } from './utils';

process.env.NODE_ENV = process.env.NODE_ENV || 'production';

// avoid ESLint errors
const logger = console;

program
.version(packageJson.version)
.option('-s, --static-dir <dir-names>', 'Directory where to load static files from', parseList)
Expand Down Expand Up @@ -66,13 +64,13 @@ if (program.staticDir) {
logger.error(`Error: no such directory to load static files: ${dir}`);
process.exit(-1);
}
logger.log(`=> Copying static files from: ${dir}`);
logger.info(`=> Copying static files from: ${dir}`);
shelljs.cp('-r', `${dir}/*`, outputDir);
});
}

// compile all resources with webpack and write them to the disk.
logger.log('Building storybook ...');
logger.info('Building storybook ...');
webpack(config).run((err, stats) => {
if (err || stats.hasErrors()) {
logger.error('Failed to build the storybook');
Expand Down
4 changes: 1 addition & 3 deletions app/angular/src/server/config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/* eslint-disable global-require, import/no-dynamic-require */
import fs from 'fs';
import path from 'path';
import { logger } from '@storybook/node-logger';
import loadBabelConfig from './babel_config';
import loadTsConfig from './ts_config';
import {
getAngularCliWebpackConfigOptions,
applyAngularCliWebpackConfig,
} from './angular-cli_config';

// avoid ESLint errors
const logger = console;

// `baseConfig` is a webpack configuration bundled with storybook.
// Storybook will look in the `configDir` directory
// (inside working directory) if a config path is not provided.
Expand Down
5 changes: 2 additions & 3 deletions app/angular/src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import path from 'path';
import fs from 'fs';
import chalk from 'chalk';
import shelljs from 'shelljs';
import { logger } from '@storybook/node-logger';
import storybook, { webpackValid } from './middleware';
import packageJson from '../../package.json';
import { parseList, getEnvConfig } from './utils';

process.env.NODE_ENV = process.env.NODE_ENV || 'development';

const logger = console;

program
.version(packageJson.version)
.option('-p, --port [number]', 'Port to run Storybook (Required)', parseInt)
Expand Down Expand Up @@ -105,7 +104,7 @@ if (program.staticDir) {
logger.error(`Error: no such directory to load static files: ${staticPath}`);
process.exit(-1);
}
logger.log(`=> Loading static files from: ${staticPath} .`);
logger.info(`=> Loading static files from: ${staticPath} .`);
app.use(express.static(staticPath, { index: false }));

const faviconPath = path.resolve(staticPath, 'favicon.ico');
Expand Down
4 changes: 1 addition & 3 deletions app/angular/src/server/ts_config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import fs from 'fs';
import path from 'path';

// avoid ESLint errors
const logger = console;
import { logger } from '@storybook/node-logger';

function resolveTsConfig(tsConfigPath) {
if (!fs.existsSync(tsConfigPath)) {
Expand Down

0 comments on commit 44ec036

Please sign in to comment.