From 9cd3ee19a37c65bc53085e37c8a05b4caf0ef686 Mon Sep 17 00:00:00 2001 From: Michael Mauderer Date: Sat, 27 Mar 2021 17:02:43 +0100 Subject: [PATCH] chore: Run `watch` build command with clean repo without failing. --- CHANGELOG.md | 4 ++++ build/run.js | 52 ++++++++++++++++++++++++++++++++-------------------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b8f5d7cf3..1befe22c70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,9 @@ with a browser of your choice. - [JS visualizations have consistent gestures with the IDE][1291]. Panning and zooming now works just as expected on trackpad and mouse. +- [Running `watch` command works on first try.][1395]. Running the build command + `run watch` would fail if it was run as the first command on a clean + repository. This now works. #### EnsoGL (rendering engine) @@ -84,6 +87,7 @@ you can find their release notes [1341]: https://github.com/enso-org/ide/pull/1341 [1348]: https://github.com/enso-org/ide/pull/1348 [1353]: https://github.com/enso-org/ide/pull/1353 +[1395]: https://github.com/enso-org/ide/pull/1395
diff --git a/build/run.js b/build/run.js index b047a91ea1..a73d83cf90 100755 --- a/build/run.js +++ b/build/run.js @@ -263,7 +263,16 @@ commands['toml-fmt'].rust = async function() { commands.watch = command(`Start a file-watch utility and run interactive mode`) commands.watch.options = Object.assign({},commands.build.options) commands.watch.parallel = false -commands.watch.rust = async function(argv) { +commands.watch.common = async function(argv) { + + // Init JS build and project manager. + await installJsDeps() + let project_manager_ready = null; + if (argv.backend !== 'false') { + await build_project_manager().then(run_project_manager) + } + + // Init Rust build. let build_args = [] if (argv.crate !== undefined) { build_args.push(`--crate=${argv.crate}`) @@ -274,22 +283,20 @@ commands.watch.rust = async function(argv) { `node ${paths.script.main} build --skip-version-validation --no-js --dev ${build_args} -- ` + cargoArgs.join(' ') + '"' + + // Run watch processes. let args = ['watch', '-s', `${target}`] - await cmd.with_cwd(paths.rust.root, async () => { - cmd.run('cargo',args) + let rust_process = cmd.with_cwd(paths.rust.root, async () => { + return cmd.run('cargo',args) }) -} -commands.watch.js = async function(argv) { - await installJsDeps() - if (argv.backend !== 'false') { - build_project_manager().then(run_project_manager) - } - await cmd.with_cwd(paths.js.root, async () => { - run('npm',['run','watch']); + let js_process = cmd.with_cwd(paths.js.root, async () => { + return run('npm',['run','watch']); }) -} + await rust_process + await js_process +} // === Dist === @@ -517,18 +524,23 @@ async function runCommand(command,argv) { cargoArgs = cargoArgs.slice(0,index) } let runner = async function () { - let do_rust = argv.rust && config.rust - let do_js = argv.js && config.js - let rustCmd = () => cmd.with_cwd(paths.rust.root, async () => await config.rust(argv)) - let jsCmd = () => cmd.with_cwd(paths.js.root , async () => await config.js(argv)) + let do_common = config.common + let do_rust = argv.rust && config.rust + let do_js = argv.js && config.js + + let commonCmd = () => cmd.with_cwd(paths.root, async () => await config.common(argv)) + let rustCmd = () => cmd.with_cwd(paths.rust.root, async () => await config.rust(argv)) + let jsCmd = () => cmd.with_cwd(paths.js.root , async () => await config.js(argv)) if(config.parallel) { let promises = [] - if (do_rust) { promises.push(rustCmd()) } - if (do_js) { promises.push(jsCmd()) } + if (do_common ) { promises.push(commonCmd()) } + if (do_rust) { promises.push(rustCmd()) } + if (do_js) { promises.push(jsCmd()) } await Promise.all(promises) } else { - if (do_rust) { await rustCmd() } - if (do_js) { await jsCmd() } + if (do_common) { await commonCmd() } + if (do_rust) { await rustCmd() } + if (do_js) { await jsCmd() } } } cmd.section(command)