Skip to content

Commit b0c530b

Browse files
authored
Merge pull request #41 from open-wc/fix/outdir
fix: outdir package.json location
2 parents cfb49ad + 98ac34c commit b0c530b

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

packages/analyzer/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ import {
9898
}
9999

100100
try {
101-
addCustomElementsPropertyToPackageJson();
101+
addCustomElementsPropertyToPackageJson(mergedOptions.outdir);
102102
} catch {
103103
console.log(`Could not add 'customElements' property to ${process.cwd()}${path.sep}package.json. \nAdding this property helps tooling locate your Custom Elements Manifest. Please consider adding it yourself, or file an issue if you think this is a bug.\nhttps://www.github.com/open-wc/custom-elements-manifest`);
104104
}

packages/analyzer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@custom-elements-manifest/analyzer",
3-
"version": "0.3.3",
3+
"version": "0.3.4",
44
"description": "",
55
"license": "MIT",
66
"type": "module",

packages/analyzer/src/utils/cli.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,18 @@ export function timestamp() {
9191
return `${date.getHours()}:${date.getMinutes()}:${date.getSeconds() < 10 ? `0${date.getSeconds()}` : date.getSeconds() }`;
9292
}
9393

94-
export function addCustomElementsPropertyToPackageJson() {
94+
export function addCustomElementsPropertyToPackageJson(outdir) {
9595
const packageJsonPath = `${process.cwd()}${path.sep}package.json`;
9696
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString());
97-
97+
9898
if(packageJson?.customElements) {
99+
if(packageJson?.customElements !== path.join(outdir, 'custom-elements.json')) {
100+
packageJson.customElements = path.join(outdir, 'custom-elements.json');
101+
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
102+
}
99103
return;
100104
} else {
101-
packageJson.customElements = 'custom-elements.json';
105+
packageJson.customElements = path.join(outdir, 'custom-elements.json');
102106
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
103107
}
104108
}
@@ -112,6 +116,7 @@ Available commands:
112116
| analyze | | Analyze your components | |
113117
| --globs | string[] | Globs to analyze | \`--globs "foo.js"\` |
114118
| --exclude | string[] | Globs to exclude | \`--exclude "foo.js"\` |
119+
| --outdir | string | Directory to output the Manifest to | \`--outdir dist\` |
115120
| --watch | boolean | Enables watch mode, generates a new manifest on file change | \`--watch\` |
116121
| --dev | boolean | Enables extra logging for debugging | \`--dev\` |
117122
| --litelement | boolean | Enable special handling for LitElement syntax | \`--litelement\` |

0 commit comments

Comments
 (0)