enso/gui/run

43 lines
1.3 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env node
let cmd = require('./build/lib/cmd')
let fss = require('fs')
let fs = require('fs').promises
let args = process.argv.slice(2)
let no_validation = '--no-validation'
async function init () {
if(!args.includes(no_validation)) {
await cmd.check_version('npm','6.13.4',{silent:true})
await cmd.check_version('node','v12.16.1',{silent:true})
await cmd.check_version('rustc','1.40.0-nightly',{preprocess:(v)=>v.substring(6,20),silent:true})
}
let initialized = fss.existsSync('target/.initialized')
if (!initialized) {
cmd.section('Initialization')
console.log('Installing build script dependencies.')
await cmd.with_cwd('build', async () => {
await cmd.run('npm',['install'])
})
if(args[0] == 'clean') {
try { await fs.unlink('target/.initialized') } catch {}
} else {
console.log('Installing application dependencies')
await cmd.with_cwd('app', async () => {
await cmd.run('npm',['run','install'])
})
await fs.mkdir('target', {recursive:true})
await fs.open('target/.initialized','w')
}
}
}
async function main() {
await init()
cmd.run('node',['./build/run'].concat(args))
}
main()