pkgbld 1.27.0 → 1.27.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.js +25 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -844,7 +844,7 @@ async function writeJson(path, json) {
|
|
|
844
844
|
await fs.writeFile(path, toFormattedJson(json));
|
|
845
845
|
}
|
|
846
846
|
|
|
847
|
-
var version = "1.27.
|
|
847
|
+
var version = "1.27.1";
|
|
848
848
|
var name = "pkgbld";
|
|
849
849
|
var license = "MIT";
|
|
850
850
|
var author = "Konstantin Shutkin";
|
|
@@ -1176,6 +1176,23 @@ async function flatten(pkg, flatten, logger) {
|
|
|
1176
1176
|
});
|
|
1177
1177
|
files.push(...newFiles);
|
|
1178
1178
|
pkg.files = [...files];
|
|
1179
|
+
// remove extra directories with package.json
|
|
1180
|
+
const exports = pkg.exports ? Object.keys(pkg.exports) : [];
|
|
1181
|
+
for (const key of exports) {
|
|
1182
|
+
if (key === '.') {
|
|
1183
|
+
continue;
|
|
1184
|
+
}
|
|
1185
|
+
const isDir = await isDirectory(key);
|
|
1186
|
+
if (isDir) {
|
|
1187
|
+
const pkgPath = path.join(key, 'package.json');
|
|
1188
|
+
const pkgExists = await isExists(pkgPath);
|
|
1189
|
+
// ensure nothing else is in the directory
|
|
1190
|
+
const files = await fs.readdir(key);
|
|
1191
|
+
if (files.length === 1 && pkgExists) {
|
|
1192
|
+
await fs.rm(key, { recursive: true, force: true });
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1179
1196
|
}
|
|
1180
1197
|
function cloneAndUpdate(pkg, updater) {
|
|
1181
1198
|
if (typeof pkg === 'string') {
|
|
@@ -1193,6 +1210,13 @@ function cloneAndUpdate(pkg, updater) {
|
|
|
1193
1210
|
}
|
|
1194
1211
|
return pkg;
|
|
1195
1212
|
}
|
|
1213
|
+
async function isDirectory(file) {
|
|
1214
|
+
try {
|
|
1215
|
+
const fileStat = await fs.stat(file);
|
|
1216
|
+
return fileStat.isDirectory();
|
|
1217
|
+
}
|
|
1218
|
+
catch (e) { /**/ }
|
|
1219
|
+
}
|
|
1196
1220
|
async function isExists(file) {
|
|
1197
1221
|
try {
|
|
1198
1222
|
await fs.access(file);
|
package/package.json
CHANGED