Skip to content

Commit

Permalink
Change prepack npm script to prepare (take 2) (#1755)
Browse files Browse the repository at this point in the history
* update truffle to include bugfix

* change prepack script to prepare

* add npx in compile script

* fix for older node

* rename script file to prepare

(cherry picked from commit 036dd9b)
  • Loading branch information
frangio committed May 22, 2019
1 parent ca922c8 commit 96fbe82
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 118 deletions.
115 changes: 6 additions & 109 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -20,7 +20,7 @@
"lint:js": "eslint .",
"lint:js:fix": "eslint . --fix",
"lint:sol": "solhint --max-warnings 0 \"contracts/**/*.sol\"",
"prepack": "node scripts/prepack.js",
"prepare": "node scripts/prepare.js",
"release": "scripts/release/release.sh",
"version": "scripts/release/update-changelog-release-date.js && scripts/release/update-ethpm-version.js",
"test": "scripts/test.sh"
Expand Down Expand Up @@ -62,6 +62,6 @@
"solhint": "^1.5.0",
"solidity-coverage": "github:rotcivegaf/solidity-coverage#5875f5b7bc74d447f3312c9c0e9fc7814b482477",
"solidity-docgen": "^0.2.0-alpha.0",
"truffle": "^5.0.0"
"truffle": "^5.0.18"
}
}
5 changes: 1 addition & 4 deletions scripts/compile.sh
Expand Up @@ -4,7 +4,4 @@ if [ "$SOLC_NIGHTLY" = true ]; then
docker pull ethereum/solc:nightly
fi

# Necessary to avoid an error in Truffle
rm -rf build/contracts

truffle compile
npx truffle compile
8 changes: 5 additions & 3 deletions scripts/prepack.js → scripts/prepare.js
Expand Up @@ -22,11 +22,13 @@ const pkgFiles = readJSON('package.json').files;
// Get only negated patterns.
const ignorePatterns = pkgFiles
.filter(pat => pat.startsWith('!'))
// Add **/* to ignore all files contained in the directories.
.flatMap(pat => [pat, path.join(pat, '**/*')])
// Remove the negation part. Makes micromatch usage more intuitive.
.map(pat => pat.slice(1));

const ignorePatternsSubtrees = ignorePatterns
// Add **/* to ignore all files contained in the directories.
.concat(ignorePatterns.map(pat => path.join(pat, '**/*')));

const artifactsDir = 'build/contracts';

let n = 0;
Expand All @@ -36,7 +38,7 @@ for (const artifact of fs.readdirSync(artifactsDir)) {
const { sourcePath: fullSourcePath } = readJSON(fullArtifactPath);
const sourcePath = path.relative('.', fullSourcePath);

const ignore = match.any(sourcePath, ignorePatterns);
const ignore = match.any(sourcePath, ignorePatternsSubtrees);

if (ignore) {
fs.unlinkSync(fullArtifactPath);
Expand Down

0 comments on commit 96fbe82

Please sign in to comment.