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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Themes: Run postinstall in shell for windows #24389

Merged
merged 4 commits into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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']);
};