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

Commit

Permalink
fix: Check if files exists in package.json (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
ffflorian authored Oct 18, 2019
1 parent 717a3b0 commit 5ea9ef2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
},
"dependencies": {
"@expo/spawn-async": "1.5.0",
"@schemastore/package": "0.0.5",
"commander": "3.0.2",
"commander-remaining-args": "1.2.0",
"fs-extra": "8.1.0",
Expand Down
16 changes: 10 additions & 6 deletions src/PublishFlat.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import spawnAsync from '@expo/spawn-async';
import {CoreProperties as PackageJson} from '@schemastore/package';
import fs from 'fs-extra';
import logdown from 'logdown';
import packlist from 'npm-packlist';
Expand Down Expand Up @@ -115,12 +116,15 @@ 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))
.filter((fileName: string) => fileName !== this.dirToFlatten)
.sort();
const packageJson: PackageJson = await fs.readJSON(filePath);

if (Array.isArray(packageJson.files)) {
packageJson.files = packageJson.files
.map(fileName => fileName.replace(this.dirToFlattenRegex, ''))
.concat(filesInFlattenedDir.map(({replacedFilename}) => replacedFilename))
.filter(fileName => fileName !== this.dirToFlatten)
.sort();
}

if (typeof packageJson.bin === 'string') {
packageJson.bin = packageJson.bin.replace(this.dirToFlattenRegex, '');
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@
dependencies:
any-observable "^0.3.0"

"@schemastore/package@0.0.5":
version "0.0.5"
resolved "https://registry.npmjs.org/@schemastore/package/-/package-0.0.5.tgz#67b621d5c833ad2d5a29a1acf868717b7839bb8a"
integrity sha512-0XEiMT/Rh8I0SEIO81fo5MN3AHhONFv9SJ1IIJ5OTI3PN/jG032OPlHUMxvrun7yc6YUGtufVg2WPQVK8PaH5Q==

"@semantic-release/changelog@3.0.4":
version "3.0.4"
resolved "https://registry.npmjs.org/@semantic-release/changelog/-/changelog-3.0.4.tgz#8fc578b76bca5b23c3000694277c38e0fa835edd"
Expand Down

0 comments on commit 5ea9ef2

Please sign in to comment.