-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24389 from storybookjs/postinstall/themes
Themes: Run postinstall in shell for windows (cherry picked from commit 6b930ec)
- Loading branch information
1 parent
eea73f8
commit 69afa64
Showing
1 changed file
with
14 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']); | ||
}; |