@storybook/core-common 6.4.10 → 6.4.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -79,35 +79,30 @@ var normalizeStoriesEntry = function (entry, {
79
79
  var specifierWithoutMatcher;
80
80
 
81
81
  if (typeof entry === 'string') {
82
- if (!entry.includes('*')) {
83
- if (isDirectory(configDir, entry)) {
84
- specifierWithoutMatcher = {
85
- titlePrefix: DEFAULT_TITLE_PREFIX,
86
- directory: entry,
87
- files: DEFAULT_FILES
88
- };
89
- } else {
90
- specifierWithoutMatcher = {
91
- titlePrefix: DEFAULT_TITLE_PREFIX,
92
- directory: _path.default.dirname(entry),
93
- files: _path.default.basename(entry)
94
- };
95
- }
96
- } else {
97
- var fixedEntry = detectBadGlob(entry);
98
- var globResult = (0, _picomatch.scan)(fixedEntry);
99
-
100
- var _directory = globResult.isGlob ? globResult.prefix + globResult.base : _path.default.dirname(fixedEntry);
101
-
102
- var filesFallback = _directory !== '.' ? fixedEntry.substr(_directory.length + 1) : fixedEntry;
82
+ var fixedEntry = detectBadGlob(entry);
83
+ var globResult = (0, _picomatch.scan)(fixedEntry);
103
84
 
104
- var _files = globResult.isGlob ? globResult.glob : filesFallback;
85
+ if (globResult.isGlob) {
86
+ var _directory = globResult.prefix + globResult.base;
105
87
 
88
+ var _files = globResult.glob;
106
89
  specifierWithoutMatcher = {
107
90
  titlePrefix: DEFAULT_TITLE_PREFIX,
108
91
  directory: _directory,
109
92
  files: _files
110
93
  };
94
+ } else if (isDirectory(configDir, entry)) {
95
+ specifierWithoutMatcher = {
96
+ titlePrefix: DEFAULT_TITLE_PREFIX,
97
+ directory: entry,
98
+ files: DEFAULT_FILES
99
+ };
100
+ } else {
101
+ specifierWithoutMatcher = {
102
+ titlePrefix: DEFAULT_TITLE_PREFIX,
103
+ directory: _path.default.dirname(entry),
104
+ files: _path.default.basename(entry)
105
+ };
111
106
  }
112
107
  } else {
113
108
  specifierWithoutMatcher = _objectSpread({
@@ -50,9 +50,9 @@ var nodePathsToArray = function (nodePath) {
50
50
  };
51
51
 
52
52
  exports.nodePathsToArray = nodePathsToArray;
53
- var relativePattern = /^\.{1,2}[/\\]/;
53
+ var relativePattern = /^\.{1,2}([/\\]|$)/;
54
54
  /**
55
- * Ensures that a path starts with `./` or `../`
55
+ * Ensures that a path starts with `./` or `../`, or is entirely `.` or `..`
56
56
  */
57
57
 
58
58
  function normalizeStoryPath(filename) {
@@ -15,7 +15,7 @@ var toRequireContext = function (specifier) {
15
15
  var match = (0, _globToRegexp.globToRegexp)(`./${files}`);
16
16
  return {
17
17
  path: directory,
18
- recursive: !!files.match(/^\*{1,2}\//),
18
+ recursive: files.includes('**') || files.split('/').length > 1,
19
19
  match: match
20
20
  };
21
21
  };
@@ -57,35 +57,30 @@ export var normalizeStoriesEntry = function (entry, {
57
57
  var specifierWithoutMatcher;
58
58
 
59
59
  if (typeof entry === 'string') {
60
- if (!entry.includes('*')) {
61
- if (isDirectory(configDir, entry)) {
62
- specifierWithoutMatcher = {
63
- titlePrefix: DEFAULT_TITLE_PREFIX,
64
- directory: entry,
65
- files: DEFAULT_FILES
66
- };
67
- } else {
68
- specifierWithoutMatcher = {
69
- titlePrefix: DEFAULT_TITLE_PREFIX,
70
- directory: path.dirname(entry),
71
- files: path.basename(entry)
72
- };
73
- }
74
- } else {
75
- var fixedEntry = detectBadGlob(entry);
76
- var globResult = scan(fixedEntry);
77
-
78
- var _directory = globResult.isGlob ? globResult.prefix + globResult.base : path.dirname(fixedEntry);
79
-
80
- var filesFallback = _directory !== '.' ? fixedEntry.substr(_directory.length + 1) : fixedEntry;
60
+ var fixedEntry = detectBadGlob(entry);
61
+ var globResult = scan(fixedEntry);
81
62
 
82
- var _files = globResult.isGlob ? globResult.glob : filesFallback;
63
+ if (globResult.isGlob) {
64
+ var _directory = globResult.prefix + globResult.base;
83
65
 
66
+ var _files = globResult.glob;
84
67
  specifierWithoutMatcher = {
85
68
  titlePrefix: DEFAULT_TITLE_PREFIX,
86
69
  directory: _directory,
87
70
  files: _files
88
71
  };
72
+ } else if (isDirectory(configDir, entry)) {
73
+ specifierWithoutMatcher = {
74
+ titlePrefix: DEFAULT_TITLE_PREFIX,
75
+ directory: entry,
76
+ files: DEFAULT_FILES
77
+ };
78
+ } else {
79
+ specifierWithoutMatcher = {
80
+ titlePrefix: DEFAULT_TITLE_PREFIX,
81
+ directory: path.dirname(entry),
82
+ files: path.basename(entry)
83
+ };
89
84
  }
90
85
  } else {
91
86
  specifierWithoutMatcher = _objectSpread({
@@ -30,9 +30,9 @@ export var nodePathsToArray = function (nodePath) {
30
30
  return path.resolve('./', p);
31
31
  });
32
32
  };
33
- var relativePattern = /^\.{1,2}[/\\]/;
33
+ var relativePattern = /^\.{1,2}([/\\]|$)/;
34
34
  /**
35
- * Ensures that a path starts with `./` or `../`
35
+ * Ensures that a path starts with `./` or `../`, or is entirely `.` or `..`
36
36
  */
37
37
 
38
38
  export function normalizeStoryPath(filename) {
@@ -7,7 +7,7 @@ export var toRequireContext = function (specifier) {
7
7
  var match = globToRegexp(`./${files}`);
8
8
  return {
9
9
  path: directory,
10
- recursive: !!files.match(/^\*{1,2}\//),
10
+ recursive: files.includes('**') || files.split('/').length > 1,
11
11
  match: match
12
12
  };
13
13
  };
@@ -57,35 +57,30 @@ export var normalizeStoriesEntry = function (entry, {
57
57
  var specifierWithoutMatcher;
58
58
 
59
59
  if (typeof entry === 'string') {
60
- if (!entry.includes('*')) {
61
- if (isDirectory(configDir, entry)) {
62
- specifierWithoutMatcher = {
63
- titlePrefix: DEFAULT_TITLE_PREFIX,
64
- directory: entry,
65
- files: DEFAULT_FILES
66
- };
67
- } else {
68
- specifierWithoutMatcher = {
69
- titlePrefix: DEFAULT_TITLE_PREFIX,
70
- directory: path.dirname(entry),
71
- files: path.basename(entry)
72
- };
73
- }
74
- } else {
75
- var fixedEntry = detectBadGlob(entry);
76
- var globResult = scan(fixedEntry);
77
-
78
- var _directory = globResult.isGlob ? globResult.prefix + globResult.base : path.dirname(fixedEntry);
79
-
80
- var filesFallback = _directory !== '.' ? fixedEntry.substr(_directory.length + 1) : fixedEntry;
60
+ var fixedEntry = detectBadGlob(entry);
61
+ var globResult = scan(fixedEntry);
81
62
 
82
- var _files = globResult.isGlob ? globResult.glob : filesFallback;
63
+ if (globResult.isGlob) {
64
+ var _directory = globResult.prefix + globResult.base;
83
65
 
66
+ var _files = globResult.glob;
84
67
  specifierWithoutMatcher = {
85
68
  titlePrefix: DEFAULT_TITLE_PREFIX,
86
69
  directory: _directory,
87
70
  files: _files
88
71
  };
72
+ } else if (isDirectory(configDir, entry)) {
73
+ specifierWithoutMatcher = {
74
+ titlePrefix: DEFAULT_TITLE_PREFIX,
75
+ directory: entry,
76
+ files: DEFAULT_FILES
77
+ };
78
+ } else {
79
+ specifierWithoutMatcher = {
80
+ titlePrefix: DEFAULT_TITLE_PREFIX,
81
+ directory: path.dirname(entry),
82
+ files: path.basename(entry)
83
+ };
89
84
  }
90
85
  } else {
91
86
  specifierWithoutMatcher = _objectSpread({
@@ -30,9 +30,9 @@ export var nodePathsToArray = function (nodePath) {
30
30
  return path.resolve('./', p);
31
31
  });
32
32
  };
33
- var relativePattern = /^\.{1,2}[/\\]/;
33
+ var relativePattern = /^\.{1,2}([/\\]|$)/;
34
34
  /**
35
- * Ensures that a path starts with `./` or `../`
35
+ * Ensures that a path starts with `./` or `../`, or is entirely `.` or `..`
36
36
  */
37
37
 
38
38
  export function normalizeStoryPath(filename) {
@@ -7,7 +7,7 @@ export var toRequireContext = function (specifier) {
7
7
  var match = globToRegexp(`./${files}`);
8
8
  return {
9
9
  path: directory,
10
- recursive: !!files.match(/^\*{1,2}\//),
10
+ recursive: files.includes('**') || files.split('/').length > 1,
11
11
  match: match
12
12
  };
13
13
  };
@@ -2,6 +2,6 @@ export declare const getProjectRoot: () => string;
2
2
  export declare const nodeModulesPaths: string;
3
3
  export declare const nodePathsToArray: (nodePath: string) => string[];
4
4
  /**
5
- * Ensures that a path starts with `./` or `../`
5
+ * Ensures that a path starts with `./` or `../`, or is entirely `.` or `..`
6
6
  */
7
7
  export declare function normalizeStoryPath(filename: string): string;
@@ -2,6 +2,6 @@ export declare const getProjectRoot: () => string;
2
2
  export declare const nodeModulesPaths: string;
3
3
  export declare const nodePathsToArray: (nodePath: string) => string[];
4
4
  /**
5
- * Ensures that a path starts with `./` or `../`
5
+ * Ensures that a path starts with `./` or `../`, or is entirely `.` or `..`
6
6
  */
7
7
  export declare function normalizeStoryPath(filename: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/core-common",
3
- "version": "6.4.10",
3
+ "version": "6.4.15",
4
4
  "description": "Storybook framework-agnostic API",
5
5
  "keywords": [
6
6
  "storybook"
@@ -61,7 +61,7 @@
61
61
  "@babel/preset-react": "^7.12.10",
62
62
  "@babel/preset-typescript": "^7.12.7",
63
63
  "@babel/register": "^7.12.1",
64
- "@storybook/node-logger": "6.4.10",
64
+ "@storybook/node-logger": "6.4.15",
65
65
  "@storybook/semver": "^7.3.2",
66
66
  "@types/node": "^14.0.10",
67
67
  "@types/pretty-hrtime": "^1.0.0",
@@ -110,6 +110,6 @@
110
110
  "publishConfig": {
111
111
  "access": "public"
112
112
  },
113
- "gitHead": "ed6c4a7d9c14d705499c118b0bac33c57de7ebe0",
113
+ "gitHead": "63a20d785f0288b86aed9e29180abbb07eb3ba8e",
114
114
  "sbmodern": "dist/modern/index.js"
115
115
  }