Skip to content

Commit

Permalink
chore: update clear-package-dir to check files array (#26645)
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet committed Aug 26, 2020
1 parent 6eefdee commit 9898b72
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 52 deletions.
4 changes: 2 additions & 2 deletions packages/gatsby-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
"typescript": "^3.9.5"
},
"files": [
"lib",
"scripts",
"lib/",
"scripts/",
"cli.js"
],
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-cli#readme",
Expand Down
3 changes: 1 addition & 2 deletions packages/gatsby-core-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"url": "https://github.com/gatsbyjs/gatsby/issues"
},
"files": [
"dist/",
"dist/index.d.ts"
"dist/"
],
"dependencies": {
"ci-info": "2.0.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/gatsby-design-tokens/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/*.js
/__tests__
/dist
34 changes: 0 additions & 34 deletions packages/gatsby-design-tokens/.npmignore

This file was deleted.

2 changes: 1 addition & 1 deletion packages/gatsby-design-tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"directory": "packages/gatsby-design-tokens"
},
"files": [
"dist/**/*"
"dist/"
],
"scripts": {
"build": "npm run build:tokens && npm run build:theme && npm run build:theme-gatsbyjs-org",
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-legacy-polyfills/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/dist/*.js
/dist
yarn.lock
.tmp
2 changes: 1 addition & 1 deletion packages/gatsby-legacy-polyfills/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"core-js-compat": "^3.6.5"
},
"files": [
"dist/**"
"dist/"
],
"devDependencies": {
"chokidar-cli": "^2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-page-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"cross-env": "^5.2.1"
},
"files": [
"dist/*"
"dist/"
],
"engines": {
"node": ">=10.13.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-telemetry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"jest-junit": "^6.4.0"
},
"files": [
"lib",
"src"
"lib/",
"src/"
],
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-telemetry#readme",
"keywords": [
Expand Down
8 changes: 4 additions & 4 deletions packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,17 @@
"files": [
"apis.json",
"ipc.json",
"cache-dir",
"cache-dir/",
"cli.js",
"dist",
"gatsby-admin-public",
"dist/",
"gatsby-admin-public/",
"graphql.js",
"index.d.ts",
"scripts/postinstall.js",
"utils.js",
"internal.js",
"internal.d.ts",
"!cache-dir/__tests__/"
"!**/__tests__/"
],
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby#readme",
"keywords": [
Expand Down
16 changes: 14 additions & 2 deletions scripts/clear-package-dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,20 @@ const getListOfFilesToClear = ({ location, name }) => {
npmignore = npmignore.concat([`node_modules/**`])
}

const result = glob.sync(`**/*`, {
nodir: true,
let globPattern = `**/*`
// check files array in package.json and use it as glob pattern
try {
const pkg = require(`${location}/package.json`)
if (pkg.files && pkg.files.length) {
globPattern =
pkg.files.length > 1 ? `{${pkg.files.join(`,`)}}` : pkg.files[0]
}
} catch {
// do nothing
}

let result = []
result = glob.sync(globPattern, {
ignore: npmignore,
cwd: location,
})
Expand Down

0 comments on commit 9898b72

Please sign in to comment.