Bladeren bron

Change prepack npm script to prepare (take 2) (#1755)

* update truffle to include bugfix

* change prepack script to prepare

* add npx in compile script

* fix for older node

* rename script file to prepare
Francisco Giordano 6 jaren geleden
bovenliggende
commit
036dd9bd6e
4 gewijzigde bestanden met toevoegingen van 11 en 12 verwijderingen
  1. 3 3
      package-lock.json
  2. 2 2
      package.json
  3. 1 4
      scripts/compile.sh
  4. 5 3
      scripts/prepare.js

+ 3 - 3
package-lock.json

@@ -12996,9 +12996,9 @@
       "dev": true
     },
     "truffle": {
-      "version": "5.0.14",
-      "resolved": "https://registry.npmjs.org/truffle/-/truffle-5.0.14.tgz",
-      "integrity": "sha512-Mlf4S58NMyR8YZFvQLAzA+7eCaDZw6ZSa92NWXDQjy1RbUfpl08/VPa06KLT+LosQuOPZr/NSH9f0u2qxfo/Qw==",
+      "version": "5.0.18",
+      "resolved": "https://registry.npmjs.org/truffle/-/truffle-5.0.18.tgz",
+      "integrity": "sha512-aQPbWSskotSmylj4kiq73Di5X+tHl5ChlvlBAo5brHmsCzvMGIH29UA+t/rK8TRo7i7Kut0HxAgVR5i+bJteAQ==",
       "dev": true,
       "requires": {
         "app-module-path": "^2.2.0",

+ 2 - 2
package.json

@@ -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"
@@ -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.14"
+    "truffle": "^5.0.18"
   }
 }

+ 1 - 4
scripts/compile.sh

@@ -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

+ 5 - 3
scripts/prepack.js → scripts/prepare.js

@@ -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;
@@ -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);