Skip to content

Commit

Permalink
CLI: replace glob with glob-promise
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Jan 31, 2023
1 parent 4ea443c commit 55ebe5b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions code/lib/core-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"file-system-cache": "^2.0.0",
"find-up": "^5.0.0",
"fs-extra": "^11.1.0",
"glob": "^7.1.6",
"glob-promise": "^4.2.0",
"handlebars": "^4.7.7",
"lazy-universal-dotenv": "^4.0.0",
"picomatch": "^2.3.0",
Expand All @@ -85,4 +85,4 @@
"platform": "node"
},
"gitHead": "91302a6818a7794e1e8bbff01c68513b8516cb53"
}
}
11 changes: 9 additions & 2 deletions code/lib/core-common/src/utils/validate-configuration-files.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { dedent } from 'ts-dedent';
import glob from 'glob';
import { promise as glob } from 'glob-promise';
import path from 'path';
import { readConfig } from '@storybook/csf-tools';
import { once } from '@storybook/node-logger';
Expand All @@ -8,10 +8,17 @@ import { boost } from './interpret-files';

export async function validateConfigurationFiles(configDir: string) {
const extensionsPattern = `{${Array.from(boost).join(',')}}`;
const mainConfigMatches = glob.sync(path.resolve(configDir, `main${extensionsPattern}`));
const mainConfigMatches = await glob(path.resolve(configDir, `main${extensionsPattern}`));

const [mainConfigPath] = mainConfigMatches;

if (mainConfigMatches.length > 1) {
once.warn(dedent`
Multiple main files found in your configDir (${path.resolve(configDir)}).
Storybook will use the first one found and ignore the others. Please remove the extra files.
`);
}

if (!mainConfigPath) {
throw new Error(dedent`
No configuration files have been found in your configDir (${path.resolve(configDir)}).
Expand Down
11 changes: 7 additions & 4 deletions code/yarn.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# This file is generated by running "yarn install" inside your project.
# Manual changes might be lost - proceed with caution!

__metadata:
version: 6
cacheKey: 8c0
Expand Down Expand Up @@ -6059,9 +6062,9 @@ __metadata:
resolution: "@storybook/core-common@workspace:lib/core-common"
dependencies:
"@babel/core": ^7.20.2
"@storybook/csf-tools": 7.0.0-beta.36
"@storybook/node-logger": 7.0.0-beta.36
"@storybook/types": 7.0.0-beta.36
"@storybook/csf-tools": 7.0.0-beta.38
"@storybook/node-logger": 7.0.0-beta.38
"@storybook/types": 7.0.0-beta.38
"@types/babel__core": ^7.1.20
"@types/express": ^4.7.0
"@types/mock-fs": ^4.13.1
Expand All @@ -6075,7 +6078,7 @@ __metadata:
file-system-cache: ^2.0.0
find-up: ^5.0.0
fs-extra: ^11.1.0
glob: ^7.1.6
glob-promise: ^4.2.0
handlebars: ^4.7.7
lazy-universal-dotenv: ^4.0.0
mock-fs: ^5.2.0
Expand Down

0 comments on commit 55ebe5b

Please sign in to comment.