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
  • Loading branch information
yannbf authored Oct 18, 2023
2 parents b5f5bb4 + ac81c13 commit 6b930ec
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 6b930ec

Please sign in to comment.