Skip to content
This repository has been archived by the owner on Feb 5, 2023. It is now read-only.

Commit

Permalink
fix: Sort files in flattened package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
ffflorian committed Aug 26, 2019
1 parent f6279d3 commit cf61552
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/PublishFlat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class PublishFlat {
throw new Error(`Files don't include a "package.json" file`);
}

const {normalFiles, filesInFlattenedDir: filesInFlattenedDir} = files.reduce(
const {normalFiles, filesInFlattenedDir} = files.reduce(
(result: Categorized, fileName: string) => {
if (this.dirToFlattenRegex.test(fileName)) {
const replacedFilename = fileName.replace(this.dirToFlattenRegex, '');
Expand Down Expand Up @@ -118,8 +118,10 @@ export class PublishFlat {
private async cleanPackageJson(filePath: string, filesInFlattenedDir: FilesInFlattenedDir): Promise<void> {
const packageJson = await fs.readJSON(filePath);
packageJson.files = packageJson.files.map((fileName: string) => fileName.replace(this.dirToFlattenRegex, ''));
packageJson.files = packageJson.files.concat(filesInFlattenedDir.map(({replacedFilename}) => replacedFilename));
packageJson.files = packageJson.files.filter((fileName: string) => fileName !== this.dirToFlatten);
packageJson.files = packageJson.files
.concat(filesInFlattenedDir.map(({replacedFilename}) => replacedFilename))
.filter((fileName: string) => fileName !== this.dirToFlatten)
.sort();

if (typeof packageJson.bin === 'string') {
packageJson.bin = packageJson.bin.replace(this.dirToFlattenRegex, '');
Expand Down

0 comments on commit cf61552

Please sign in to comment.