Skip to content

Commit 2adb96d

Browse files
committed
Fix the resource lookup for starterkits
1 parent 061348c commit 2adb96d

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"publish": "npx lerna publish -m \"[skip travis] chore(release): publish %s\"",
4242
"postpublish": "auto release",
4343
"preview:docs": "cd packages/docs && yarn production",
44-
"preview:hbs": "cd packages/development-edition-engine-handlebars && npx patternlab add --starterkits @pattern-lab/starterkit-handlebars-vanilla && npm run pl:build"
44+
"preview:hbs": "cd packages/development-edition-engine-handlebars && yarn pl:starterkit && yarn pl:build"
4545
},
4646
"nyc": {
4747
"exclude": [

packages/cli/bin/install-starterkit.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const {
88
readJsonAsync,
99
} = require('./utils');
1010
const {
11-
resolveFileInPackage,
11+
resolvePackageFolder,
1212
resolveDirInPackage,
1313
} = require('@pattern-lab/core/src/lib/resolver');
1414

@@ -19,7 +19,10 @@ const installStarterkit = (starterkit, config) =>
1919
yield checkAndInstallPackage(name);
2020
yield copyAsync(resolveDirInPackage(name, 'dist'), path.resolve(sourceDir));
2121
let kitConfig;
22-
const kitConfigPath = resolveFileInPackage(name, 'patternlab-config.json');
22+
const kitConfigPath = path.join(
23+
resolvePackageFolder(name),
24+
'patternlab-config.json'
25+
);
2326
if (fs.existsSync(kitConfigPath)) {
2427
kitConfig = yield readJsonAsync(kitConfigPath);
2528
}

packages/core/src/lib/resolver.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@ const resolveFileInPackage = (packageName, ...pathElements) => {
1010
return require.resolve(path.join(packageName, ...pathElements));
1111
};
1212

13-
/**
14-
* @func resolveDirInPackage
15-
* Resolves a file inside a package
16-
*/
17-
const resolveDirInPackage = (packageName, ...pathElements) => {
18-
return path.dirname(resolveFileInPackage(packageName, ...pathElements));
19-
};
20-
2113
/**
2214
* @func resolvePackageFolder
2315
* Resolves the location of a package on disc
@@ -26,6 +18,14 @@ const resolvePackageFolder = packageName => {
2618
return path.dirname(resolveFileInPackage(packageName, 'package.json'));
2719
};
2820

21+
/**
22+
* @func resolveDirInPackage
23+
* Resolves a file inside a package
24+
*/
25+
const resolveDirInPackage = (packageName, ...pathElements) => {
26+
return path.join(resolvePackageFolder(packageName), ...pathElements);
27+
};
28+
2929
module.exports = {
3030
resolveFileInPackage,
3131
resolveDirInPackage,

packages/development-edition-engine-handlebars/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"pl:help": "patternlab --help",
99
"pl:install": "patternlab install --config ./patternlab-config.json",
1010
"pl:serve": "patternlab serve --config ./patternlab-config.json",
11+
"pl:starterkit": "patternlab add --starterkits @pattern-lab/starterkit-handlebars-vanilla",
1112
"pl:version": "patternlab --version",
1213
"dev": "node ./node_modules/@pattern-lab/uikit-workshop/build-tools.js"
1314
},
@@ -33,6 +34,7 @@
3334
"@pattern-lab/engine-handlebars": "^5.10.1",
3435
"@pattern-lab/engine-mustache": "^5.12.0",
3536
"@pattern-lab/plugin-tab": "^5.10.1",
37+
"@pattern-lab/starterkit-handlebars-vanilla": "1.4.0",
3638
"@pattern-lab/starterkit-mustache-demo": "^5.0.0",
3739
"@pattern-lab/uikit-workshop": "^5.12.0"
3840
}

0 commit comments

Comments
 (0)