Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 27aff37

Browse files
committedMay 21, 2020
fix: don't replace files field during init
1 parent ffc6e18 commit 27aff37

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed
 

‎src/cli.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,20 @@ yargs
212212
JSON.stringify(pkg.files.slice().sort()) !==
213213
JSON.stringify(files.slice().sort())
214214
) {
215-
const { replace } = await inquirer.prompt({
215+
const { update } = await inquirer.prompt({
216216
type: 'confirm',
217-
name: 'replace',
218-
message: `Your package.json already has a 'files' field. Do you want to replace it?`,
217+
name: 'update',
218+
message: `Your package.json already has a 'files' field. Do you want to update it?`,
219219
default: true,
220220
});
221221

222-
if (replace) {
223-
pkg.files = files;
222+
if (update) {
223+
pkg.files = [
224+
...files,
225+
...pkg.files.filter(
226+
(file: string) => !files.includes(file.replace(/\/$/g, ''))
227+
),
228+
];
224229
}
225230
} else {
226231
pkg.files = files;

0 commit comments

Comments
 (0)