feat: do better file detection to check that the universal file is added to the diff too

This commit is contained in:
blam
2020-12-15 21:04:15 +01:00
parent bdd10ca66f
commit a04b28ac4b
2 changed files with 23 additions and 2 deletions
+22 -1
View File
@@ -61,13 +61,34 @@ class PackageJsonHandler {
await this.syncField('main:src');
}
await this.syncField('types');
await this.syncFiles();
await this.syncScripts();
await this.syncPublishConfig();
await this.syncDependencies('dependencies');
await this.syncDependencies('devDependencies');
}
private async syncFiles() {
const hasUniversalFile = this.targetPkg.files.includes('universal.js');
const hasConfigTypeScriptFile =
typeof this.targetPkg.configSchema === 'string';
if (hasUniversalFile || hasConfigTypeScriptFile) {
const files = [...this.pkg.files];
if (hasUniversalFile) {
files.push('universal.js');
}
if (hasConfigTypeScriptFile) {
files.push(this.targetPkg.configSchema);
}
await this.syncField('files', { files });
} else {
await this.syncField('files');
}
}
// Make sure a field inside package.json is in sync. This mutates the targetObj and writes package.json on change.
private async syncField(
fieldName: string,
+1 -1
View File
@@ -64,6 +64,6 @@
},
"files": [
"dist",
"universal"
"universal.js"
]
}