Skip to content

Commit 83312d6

Browse files
committed
fix: add additional targets to postpackage rewrite script
1 parent e19de04 commit 83312d6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

scripts/postpackage.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ import { promises as fs } from 'fs';
22
import path from 'path';
33

44
const PACKAGE_FOLDER = process.env.PACKAGE_FOLDER || 'package';
5-
const TARGETS = ['components', 'config', 'src', 'stores'];
6-
const BASE_DIR = path.join(process.cwd(), PACKAGE_FOLDER);
5+
const CWD = process.cwd();
76

87
const getFolder = async (folder, depth = 0) => {
9-
const contents = await fs.readdir(path.join(process.cwd(), PACKAGE_FOLDER, folder), {
8+
const contents = await fs.readdir(path.join(CWD, folder), {
109
withFileTypes: true
1110
});
1211

@@ -24,7 +23,7 @@ const getFolder = async (folder, depth = 0) => {
2423
const transformFolder = async ({ folders, files, depth }) => {
2524
await Promise.all(
2625
files.map(async (f) => {
27-
const filepath = path.join(BASE_DIR, f);
26+
const filepath = path.join(CWD, f);
2827
const contents = await fs.readFile(filepath, 'utf-8');
2928
const base = depth ? [...Array(depth + 1).fill('..')].join('/') : './';
3029
const updated = contents.replace(/from '\$lib(.*)'/g, `from '${base}$1'`);
@@ -38,4 +37,7 @@ const transformFolder = async ({ folders, files, depth }) => {
3837
);
3938
};
4039

41-
Promise.all(TARGETS.map((t) => getFolder(t).then(transformFolder)));
40+
getFolder(PACKAGE_FOLDER)
41+
.then(transformFolder)
42+
.catch(console.error)
43+
.finally(() => process.exit());

0 commit comments

Comments
 (0)