diff --git a/ide/CHANGELOG.md b/ide/CHANGELOG.md index 027dbf2e8550..6a5083e19aa6 100644 --- a/ide/CHANGELOG.md +++ b/ide/CHANGELOG.md @@ -83,6 +83,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. - [The `inputType` field of visualizations is actually taken into consideration] [1384]. The visualization chooser shows entries accepting the node's output's type only. @@ -127,6 +130,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 [1363]: https://github.com/enso-org/ide/pull/1363 [1384]: https://github.com/enso-org/ide/pull/1384 [1385]: https://github.com/enso-org/ide/pull/1385 diff --git a/ide/build/run.js b/ide/build/run.js index 12b955e1c27e..b617a4e2b451 100755 --- a/ide/build/run.js +++ b/ide/build/run.js @@ -262,33 +262,48 @@ 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 = true -commands.watch.rust = async function(argv) { - let build_args = [] - if (argv.crate !== undefined) { - build_args.push(`--crate=${argv.crate}`) - } +commands.watch.parallel = false +commands.watch.common = async function(argv) { + argv.dev = true + + // Init JS build and project manager. + + await installJsDeps() if (argv.backend !== 'false') { - build_project_manager().then(run_project_manager) + await build_project_manager().then(run_project_manager) } - build_args = build_args.join(' ') - let target = - '"' + - `node ${paths.script.main} build --skip-version-validation --no-js --dev ${build_args} -- ` + - cargoArgs.join(' ') + - '"' - let args = ['watch', '-s', `${target}`] + // Run build processes. + await cmd.with_cwd(paths.rust.root, async () => { - await cmd.run('cargo',args) + return commands.build.rust(argv); }) -} - -commands.watch.js = async function() { - await installJsDeps() await cmd.with_cwd(paths.js.root, async () => { - await run('npm',['run','watch']) + return commands.build.js(argv) }) + + // Run watch processes. + + const rust_process = cmd.with_cwd(paths.rust.root, async () => { + let build_args = [] + if (argv.crate !== undefined) { + build_args.push(`--crate=${argv.crate}`) + } + build_args = build_args.join(' ') + const target = + '"' + + `node ${paths.script.main} build --skip-version-validation --no-js --dev ${build_args} -- ` + + cargoArgs.join(' ') + + '"' + let args = ['watch', '-s', `${target}`] + return cmd.run('cargo',args) + }) + const js_process = cmd.with_cwd(paths.js.root, async () => { + return run('npm',['run','watch']); + }) + + await rust_process + await js_process } @@ -518,18 +533,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)