Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log clientVersion on fatal error #331

Merged
merged 1 commit into from Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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