Skip to content

Commit

Permalink
Merge pull request #331 from chromaui/report-client-version
Browse files Browse the repository at this point in the history
Log clientVersion on fatal error
  • Loading branch information
ghengeveld committed Apr 30, 2021
2 parents fc7a7fd + 96c5a7a commit 6db624a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 8 additions & 4 deletions bin/tasks/build.js
Expand Up @@ -3,7 +3,7 @@ import fs from 'fs-extra';
import path from 'path';
import semver from 'semver';
import tmp from 'tmp-promise';
import yarnOrNpm, { hasYarn } from 'yarn-or-npm';
import yarnOrNpm, { spawn } from 'yarn-or-npm';

import { createTask, transitionTo } from '../lib/tasks';
import buildFailed from '../ui/messages/errors/buildFailed';
Expand All @@ -26,14 +26,18 @@ export const setSpawnParams = (ctx) => {
if (ctx.git.changedFiles && !webpackStatsSupported) {
ctx.log.warn('Storybook version 6.2.0 or later is required to use the --only-changed flag');
}
const client = yarnOrNpm();
const { stdout } = spawn.sync(['--version']);
const clientVersion = stdout && stdout.toString().trim();
ctx.spawnParams = {
client: yarnOrNpm(),
client,
clientVersion,
platform: process.platform,
command: yarnOrNpm(),
command: client,
clientArgs: ['run', '--silent'],
scriptArgs: [
ctx.options.buildScriptName,
hasYarn() ? '' : '--',
client === 'yarn' ? '' : '--',
'--output-dir',
ctx.sourceDir,
ctx.git.changedFiles && webpackStatsSupported && '--webpack-stats-json',
Expand Down
12 changes: 12 additions & 0 deletions bin/ui/messages/errors/fatalError.stories.js
Expand Up @@ -30,6 +30,18 @@ const context = {
options: {
buildScriptName: 'build:storybook',
},
spawnParams: {
client: 'npm',
clientVersion: '7.11.2',
platform: 'darwin',
command: 'npm',
clientArgs: ['run', '--silent'],
scriptArgs: ['build:storybook', '--', '--output-dir', '/tmp/path/to/output'],
spawnOptions: {
preferLocal: true,
localDir: '/path/to/node_modules/.bin',
},
},
exitCode: 255,
build: {
id: '5ec5069ae0d35e0022b6a9cc',
Expand Down

0 comments on commit 6db624a

Please sign in to comment.