Skip to content

Commit

Permalink
Merge pull request #1200 from poanetwork/fix-error-folders-in-build
Browse files Browse the repository at this point in the history
Fix error in step4 in netlify
  • Loading branch information
mariano-aguero committed Oct 24, 2018
2 parents 4bf24cf + abc32c9 commit 0d820a3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
31 changes: 30 additions & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ measureFileSizesBeforeBuild(paths.appBuild)
.then(previousFileSizes => {
// Remove all content but keep the directory so that
// if you're in it, you don't end up in Trash
fs.emptyDirSync(paths.appBuild);

deleteFolderRecursive(paths.appBuild);

// Merge with the public folder
copyPublicFolder();
// Start the webpack build
Expand Down Expand Up @@ -142,3 +144,30 @@ function copyPublicFolder() {
filter: file => file !== paths.appHtml,
});
}

function deleteFolderRecursive(pathApp) {
const pathBuild = path.join(__dirname, `../build`)
const pathContract = path.join(__dirname, `../build/contracts`)
const pathMetadata = path.join(__dirname, `../build/metadata`)

if (pathApp === pathContract || pathApp === pathMetadata) {
console.log(`Path excluded to delete: ${pathApp}`)
return
} else {
if (fs.existsSync(pathApp)) {
fs.readdirSync(pathApp).forEach(function(file) {
let curPath = `${pathApp}/${file}`
if (fs.lstatSync(curPath).isDirectory()) {
// recurse
deleteFolderRecursive(curPath)
} else {
// delete file
fs.unlinkSync(curPath)
}
})
if (pathApp !== pathBuild) {
fs.rmdirSync(pathApp)
}
}
}
}
6 changes: 5 additions & 1 deletion scripts/moveSolcVersionOutput.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Script that create a json file with the truffle version in a public folder
*/

const path = require('path')
const shell = require('shelljs')
const { writeFile } = require('./helpers/utils')

Expand Down Expand Up @@ -30,11 +31,14 @@ const createObjectVersion = (strategy, content) => {
if (!strategiesAllowed.includes(strategy)) {
throw new Error('Strategy doesnt exist')
}
const destinyPath = `${__dirname}/../${directory}/metadata/${strategy}TruffleVersions.json`

const destinyPath = path.join(__dirname, `../${directory}/metadata/${strategy}TruffleVersions.json`)

writeFile(destinyPath, content, err => {
if (err) {
console.log(`Error creating version file`, err)
} else {
console.log(`Move ${destinyPath} this content ${JSON.stringify(content)}`)
}
})
} catch (e) {
Expand Down
10 changes: 8 additions & 2 deletions scripts/moveTruffleConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Script that move truffle config to a public folder
*/

const path = require('path')
const { copyFile } = require('./helpers/utils')

const directory = process.argv.slice(2)[0] || 'public'
Expand All @@ -12,12 +13,17 @@ const copyStrategy = strategy => {
if (!strategiesAllowed.includes(strategy)) {
throw new Error('Strategy doesnt exist')
}
const originPath = `${__dirname}/../submodules/auth-os-applications/TokenWizard/crowdsale/${strategy}Crowdsale/truffle.js`
const destinyPath = `${__dirname}/../${directory}/metadata/${strategy}CrowdsaleTruffle.js`
const originPath = path.join(
__dirname,
`../submodules/auth-os-applications/TokenWizard/crowdsale/${strategy}Crowdsale/truffle.js`
)
const destinyPath = path.join(__dirname, `../${directory}/metadata/${strategy}CrowdsaleTruffle.js`)

copyFile(originPath, destinyPath, err => {
if (err) {
console.log(`Error moving files`, err)
} else {
console.log(`Move ${originPath} - Destiny ${destinyPath}`)
}
})
} catch (e) {
Expand Down

0 comments on commit 0d820a3

Please sign in to comment.