Skip to content

Commit

Permalink
Merge 46ed5df into fa004a7
Browse files Browse the repository at this point in the history
  • Loading branch information
frangio committed May 14, 2019
2 parents fa004a7 + 46ed5df commit 03b8bd6
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 111 deletions.
2 changes: 0 additions & 2 deletions contracts/.npmignore

This file was deleted.

233 changes: 152 additions & 81 deletions package-lock.json

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

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"files": [
"build",
"contracts",
"!contracts/mocks",
"!contracts/examples",
"test/behaviors"
],
"scripts": {
Expand All @@ -18,10 +20,10 @@
"lint:js": "eslint .",
"lint:js:fix": "eslint . --fix",
"lint:sol": "solhint --max-warnings 0 \"contracts/**/*.sol\"",
"prepack": "scripts/prepack.sh",
"prepack": "node scripts/prepack.js",
"release": "scripts/release/release.sh",
"version": "scripts/release/update-changelog-release-date.js && scripts/release/update-ethpm-version.js",
"test": "npm run compile && scripts/test.sh"
"test": "scripts/test.sh"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -54,6 +56,7 @@
"ethereumjs-util": "^6.0.0",
"ganache-cli": "^6.4.1",
"ganache-cli-coverage": "https://github.com/frangio/ganache-cli/releases/download/v6.4.1-coverage/ganache-cli-coverage-6.4.1.tgz",
"micromatch": "^4.0.2",
"openzeppelin-docsite": "github:OpenZeppelin/openzeppelin-docsite",
"openzeppelin-test-helpers": "^0.3.2",
"solhint": "^1.5.0",
Expand Down
3 changes: 3 additions & 0 deletions scripts/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ if [ "$SOLC_NIGHTLY" = true ]; then
docker pull ethereum/solc:nightly
fi

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

truffle compile
43 changes: 43 additions & 0 deletions scripts/prepack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env node

// This script removes the build artifacts of ignored contracts.

const fs = require('fs');
const path = require('path');
const process = require('process');
const cp = require('child_process');
const match = require('micromatch');

function exec(cmd, ...args) {
cp.execFileSync(cmd, args, { stdio: 'inherit' });
}

function readJSON(path) {
return JSON.parse(fs.readFileSync(path));
}

exec('npm', 'run', 'compile');

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 artifactsDir = 'build/contracts';

for (const artifact of fs.readdirSync(artifactsDir)) {
const fullArtifactPath = path.join(artifactsDir, artifact);
const { sourcePath: fullSourcePath } = readJSON(fullArtifactPath);
const sourcePath = path.relative('.', fullSourcePath);

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

if (ignore) {
fs.unlinkSync(fullArtifactPath);
}
}

0 comments on commit 03b8bd6

Please sign in to comment.