Skip to content

NodePackageInstallTask does not resolve absolute paths #13526

Open
@emyann

Description

@emyann

🐞 Bug report

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [x] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Description

I use @angular-devkit/schematics as a dependency in a custom CLI. I observed that when a NodePackageInstallTask is used within a NodeWorkflow where the root directory has not been provided, the working directory in new NodePackageInstallTask("/path/to/directory") is not resolved correctly and ends up with a ENOENT error.

It seems to be related to the NodeWorkflow class:

🔬 Minimal Reproduction

import { NodeJsSyncHost } from '@angular-devkit/core/node';
import { NodeWorkflow } from '@angular-devkit/schematics/tools';


const fsHost = new virtualFs.ScopedHost(new NodeJsSyncHost());
const workflow = new NodeWorkflow(fsHost, { dryRun:false });

// schematics
function schematics(){
  return (host: Tree, context: SchematicContext) => {
    const projectPath= "/home/path/to/project"
    const templateSource = apply(url(templatePath), [move(projectPath)]);
    context.addTask(new NodePackageInstallTask(projectPath));
    return chain([branchAndMerge(mergeWith(templateSource))])(host, context);
  }
}

🔥 Exception or Error


events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: spawn /bin/sh ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:229:19)
    at onErrorNT (internal/child_process.js:406:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
    at startup (internal/bootstrap/node.js:236:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:560:3)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:235:12)
    at onErrorNT (internal/child_process.js:406:16)
    [... lines matching original stack trace ...]
    at bootstrapNodeJSCore (internal/bootstrap/node.js:560:3)

🌍 Your Environment


 "@angular-devkit/core": "^7.3.0-rc.0",
 "@angular-devkit/schematics": "^7.3.0-rc.0",
  node: 10.6.0

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions