Skip to content

Commit d2aa1be

Browse files
ringodsbmuenzenmeyer
authored andcommitted
fix(cli): allow any package to be installed as a starterkit
Let any package be installed as a Patternlab starterkit. (#1067)
1 parent 18f8773 commit d2aa1be

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

packages/cli/bin/install-starterkit.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ const installStarterkit = (starterkit, config) =>
1212
wrapAsync(function*() {
1313
const sourceDir = config.paths.source.root;
1414
const name = starterkit.value || starterkit;
15-
const url = name.startsWith('@pattern-lab/') ? name : `pattern-lab/${name}`;
16-
yield checkAndInstallPackage(name, url);
15+
yield checkAndInstallPackage(name);
1716
const kitPath = path.resolve('./node_modules', name);
1817
yield copyAsync(path.resolve(kitPath, 'dist'), path.resolve(sourceDir));
1918
let kitConfig;

packages/cli/bin/utils.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,15 @@ const copyWithPattern = (cwd, pattern, dest) =>
126126
* @func fetchPackage
127127
* @desc Fetches and saves packages from npm into node_modules and adds a reference in the package.json under dependencies
128128
* @param {string} packageName - The package name
129-
* @param {string} [url] - A URL which will be used to fetch the package from
130129
*/
131-
const fetchPackage = (packageName, url) =>
130+
const fetchPackage = packageName =>
132131
wrapAsync(function*() {
133132
const useYarn = hasYarn();
134133
const pm = useYarn ? 'yarn' : 'npm';
135134
const installCmd = useYarn ? 'add' : 'install';
136135
try {
137-
if (packageName || url) {
138-
const cmd = yield spawn(pm, [installCmd, url || packageName]);
136+
if (packageName) {
137+
const cmd = yield spawn(pm, [installCmd, packageName]);
139138
error(cmd.stderr);
140139
}
141140
} catch (err) {
@@ -150,10 +149,9 @@ const fetchPackage = (packageName, url) =>
150149
* @func checkAndInstallPackage
151150
* Checks whether a package for a given packageName is installed locally. If package cannot be found, fetch and install it
152151
* @param {string} packageName - The package name
153-
* @param {string} [url] - A URL which will be used to fetch the package from
154152
* @return {boolean}
155153
*/
156-
const checkAndInstallPackage = (packageName, url) =>
154+
const checkAndInstallPackage = packageName =>
157155
wrapAsync(function*() {
158156
try {
159157
require.resolve(packageName);
@@ -162,7 +160,7 @@ const checkAndInstallPackage = (packageName, url) =>
162160
debug(
163161
`checkAndInstallPackage: ${packageName} not installed. Fetching it now …`
164162
);
165-
yield fetchPackage(packageName, url);
163+
yield fetchPackage(packageName);
166164
return false;
167165
}
168166
});

0 commit comments

Comments
 (0)