Skip to content

Commit

Permalink
Merge pull request #24389 from storybookjs/postinstall/themes
Browse files Browse the repository at this point in the history
Themes: Run postinstall in shell for windows
(cherry picked from commit 6b930ec)
  • Loading branch information
yannbf authored and storybook-bot committed Oct 19, 2023
1 parent eea73f8 commit 3064a2c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions code/addons/themes/postinstall.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
const { spawn } = require('child_process');

const PACKAGE_MANAGER_TO_COMMAND = {
npm: 'npx',
yarn1: 'npx',
yarn2: 'yarn dlx',
pnpm: 'pnpm dlx',
npm: ['npx'],
pnpm: ['pnpm', 'dlx'],
yarn1: ['npx'],
yarn2: ['yarn', 'dlx'],
};

module.exports = function postinstall(options) {
const command = PACKAGE_MANAGER_TO_COMMAND[options.packageManager];
const selectPackageManagerCommand = (packageManager) => PACKAGE_MANAGER_TO_COMMAND[packageManager];

spawn(command, ['@storybook/auto-config', 'themes'], {
const spawnPackageManagerScript = async (packageManager, args) => {
const [command, ...baseArgs] = selectPackageManagerCommand(packageManager);

await spawn(command, [...baseArgs, ...args], {
stdio: 'inherit',
cwd: process.cwd(),
shell: true,
});
};

module.exports = async function postinstall({ packageManager = 'npm' }) {
await spawnPackageManagerScript(packageManager, ['@storybook/auto-config', 'themes']);
};

0 comments on commit 3064a2c

Please sign in to comment.