Skip to content

Commit a87d019

Browse files
committed
chore: fix formatter, publish script
1 parent 742caa4 commit a87d019

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
"scripts": {
1212
"build": "lerna run build",
1313
"test": "lerna run test --stream",
14-
"format": "prettier --config .prettierrc \"packages/@pandino/*/src/**/*.{ts,tsx}\" --write",
14+
"format": "prettier --config .prettierrc \"packages/@pandino/*/src/**/*.{js,ts,tsx}\" --write",
1515
"format-examples": "prettier --config .prettierrc examples/*/packages/*/src/**/*.{ts,tsx} --write",
1616
"new-version": "lerna version --conventional-commits --yes",
17-
"new-publish": "lerna publish",
18-
"new-publish:ci": "lerna publish --yes",
17+
"new-publish": "lerna publish --conventional-commits",
18+
"new-publish:ci": "lerna publish --conventional-commits --yes",
1919
"lerna": "lerna"
2020
},
2121
"devDependencies": {

packages/@pandino/manifest-generator/src/index.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ const defaultOptions = {
88
};
99

1010
const generateManifest = (options = defaultOptions, targetFile) => {
11-
const addBundleLicenseEntry = typeof options.addBundleLicenseEntry === 'boolean' ? options.addBundleLicenseEntry : true;
12-
const bundleLicenseValue = typeof options.bundleLicenseValue === 'string' ? options.bundleLicenseValue : 'relative-path';
13-
const licenseFileRegex = typeof options.licenseFileRegex === 'string' ? options.licenseFileRegex : '^LICENSE(\\.txt)?$';
11+
const addBundleLicenseEntry =
12+
typeof options.addBundleLicenseEntry === 'boolean' ? options.addBundleLicenseEntry : true;
13+
const bundleLicenseValue =
14+
typeof options.bundleLicenseValue === 'string' ? options.bundleLicenseValue : 'relative-path';
15+
const licenseFileRegex =
16+
typeof options.licenseFileRegex === 'string' ? options.licenseFileRegex : '^LICENSE(\\.txt)?$';
1417
const defaultActivator = './' + targetFile.substring(targetFile.lastIndexOf(path.sep) + 1);
1518
const packageString = fs.readFileSync(path.resolve('package.json')).toString('utf8');
1619
const packageJson = JSON.parse(packageString);
@@ -43,10 +46,11 @@ const generateManifest = (options = defaultOptions, targetFile) => {
4346
}
4447

4548
if (addBundleLicenseEntry) {
46-
const files = fs.readdirSync(path.resolve(), { withFileTypes: true })
47-
.filter(item => !item.isDirectory())
48-
.map(item => item.name)
49-
.filter(item => item.match(new RegExp(licenseFileRegex)));
49+
const files = fs
50+
.readdirSync(path.resolve(), { withFileTypes: true })
51+
.filter((item) => !item.isDirectory())
52+
.map((item) => item.name)
53+
.filter((item) => item.match(new RegExp(licenseFileRegex)));
5054

5155
if (files.length) {
5256
switch (bundleLicenseValue) {
@@ -74,7 +78,7 @@ const generateManifest = (options = defaultOptions, targetFile) => {
7478
fs.mkdirSync(targetFolder, { recursive: true }); // ensure folder is created
7579

7680
fs.writeFileSync(targetPath, JSON.stringify(finalContent, null, 4), { encoding: 'utf8' });
77-
}
81+
};
7882

7983
module.exports = {
8084
generateManifest,
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
const { defaultOptions, generateManifest } = require('@pandino/manifest-generator');
2-
const path = require("path");
2+
const path = require('path');
33

44
const generateManifestPlugin = (options = defaultOptions) => {
5-
65
return {
76
name: 'generate-manifest',
87
writeBundle: (bundleOptions) => {
98
const targetFile = Array.isArray(bundleOptions.file) ? bundleOptions.file[0] : bundleOptions.file;
109

11-
// const target = bundleOptions.file.substring(0, bundleOptions.file.lastIndexOf('.')) + '-manifest.json';
12-
// const targetPath = path.resolve(target);
13-
// const lastSeparator = targetPath.lastIndexOf(path.sep);
14-
// const targetFolder = lastSeparator > -1 ? targetPath.substring(0, lastSeparator) : '.';
15-
1610
generateManifest(options, path.resolve(targetFile));
17-
}
18-
}
19-
}
11+
},
12+
};
13+
};
2014

2115
module.exports = generateManifestPlugin;

packages/@pandino/webpack-plugin-generate-manifest/src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ class GenerateManifestPlugin {
1212
const targetPath = compilation.options.output.path;
1313

1414
for (const chunk of Array.from(chunks)) {
15-
const targetFile = Array.from(chunk.files).find(f => f.endsWith('js') || f.endsWith('cjs') || f.endsWith('mjs'));
15+
const targetFile = Array.from(chunk.files).find(
16+
(f) => f.endsWith('js') || f.endsWith('cjs') || f.endsWith('mjs'),
17+
);
1618
generateManifest(this.options, path.resolve(path.join(targetPath, targetFile)));
1719
}
1820
});

0 commit comments

Comments
 (0)