feat: do better file detection to check that the universal file is added to the diff too
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -64,6 +64,6 @@
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"universal"
|
||||
"universal.js"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user