pkgbld 1.30.0 → 1.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +25 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -936,7 +936,7 @@ async function writeJson(path, json) {
|
|
|
936
936
|
await fs.writeFile(path, toFormattedJson(json));
|
|
937
937
|
}
|
|
938
938
|
|
|
939
|
-
var version = "1.30.
|
|
939
|
+
var version = "1.30.1";
|
|
940
940
|
var name = "pkgbld";
|
|
941
941
|
var license = "MIT";
|
|
942
942
|
var author = "Konstantin Shutkin";
|
|
@@ -1314,6 +1314,10 @@ async function flatten(pkg, flatten, logger) {
|
|
|
1314
1314
|
const expression = jsonata('[bin, bin.*, main, module, unpkg, umd, types, typings, exports[].*.*, typesVersions.*.*, directories.bin]');
|
|
1315
1315
|
const allReferences = (await expression.evaluate(pkg));
|
|
1316
1316
|
let distDir;
|
|
1317
|
+
// at this point we requested directories.bin, but it is the only one that is directory and not a file
|
|
1318
|
+
// later when we get dirname we can't flatten directories.bin completely
|
|
1319
|
+
// it is easy to fix by checking element is a directory but it is kind of good
|
|
1320
|
+
// to have it as a separate directory, but user still can flatten it by specifying the directory
|
|
1317
1321
|
if (flatten === true) {
|
|
1318
1322
|
let commonSegments;
|
|
1319
1323
|
for (const entry of allReferences) {
|
|
@@ -1337,7 +1341,7 @@ async function flatten(pkg, flatten, logger) {
|
|
|
1337
1341
|
distDir = commonSegments?.join('/');
|
|
1338
1342
|
}
|
|
1339
1343
|
else {
|
|
1340
|
-
distDir = flatten;
|
|
1344
|
+
distDir = normalizePath(flatten);
|
|
1341
1345
|
}
|
|
1342
1346
|
if (!distDir) {
|
|
1343
1347
|
throw new Error('could not find dist folder');
|
|
@@ -1357,6 +1361,25 @@ async function flatten(pkg, flatten, logger) {
|
|
|
1357
1361
|
if (filesAlreadyExist.length) {
|
|
1358
1362
|
throw new Error(`dist folder cannot be flattened because files already exist: ${filesAlreadyExist.join(', ')}`);
|
|
1359
1363
|
}
|
|
1364
|
+
if (typeof flatten === 'string' && 'directories' in pkg && pkg.directories != null
|
|
1365
|
+
&& typeof pkg.directories === 'object' && 'bin' in pkg.directories
|
|
1366
|
+
&& typeof pkg.directories.bin === 'string' && normalizePath(pkg.directories.bin) === normalizePath(flatten)) {
|
|
1367
|
+
delete pkg.directories.bin;
|
|
1368
|
+
if (Object.keys(pkg.directories).length === 0) {
|
|
1369
|
+
delete pkg.directories;
|
|
1370
|
+
}
|
|
1371
|
+
const files = await readdir(flatten);
|
|
1372
|
+
if (files.length === 1) {
|
|
1373
|
+
const file = files[0];
|
|
1374
|
+
pkg.bin = file;
|
|
1375
|
+
}
|
|
1376
|
+
else {
|
|
1377
|
+
pkg.bin = {};
|
|
1378
|
+
for (const file of files) {
|
|
1379
|
+
pkg.bin[path.basename(file, path.extname(file))] = file;
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1360
1383
|
// create new directory structure
|
|
1361
1384
|
const mkdirPromises = [];
|
|
1362
1385
|
for (const file of filesInDist) {
|
package/package.json
CHANGED