1

I'm creating a script that generates an Angular workspace using the schematics feature. My schematics has a required property:

"$id": "MySchematics",
"$schema": "http://json-schema.org/schema",
"description": "Create a workspace",
"properties": {
    "name": {
        "$default": {
            "$source": "argv",
            "index": 0
        },
        "description": "The name of the workspace",
        "type": "string",
        "x-prompt": "What name for the workspace?"
    }
},
 "required": ["name"],
 "title": "Workspace schematics",
 "type": "object"

}

My script is something like this:

const exec = require("child_process").exec;
const npm = require("npm");
exec("npm run build");
exec(
    "schematics .\\:my-schematics --debug=false"
);

Before these lines, the script makes more actions to prepare the folder before using the schematics: this is the reason why I created a script and not executed the commands directly in the prompt.

The issue is: if I execute "schematics .\:my-schematics-3-1 --debug=false" directly from the prompt, the question "What name for the workspace?" appears and the commands are executed as expected. If I execute the script, the question does not appear and the commands seems successful (no error shown), but obviously the workspace was not created (the arg "name" is required for the schematics).

If someone could help me, It will be very appreciated.

E.Tiake
  • 166
  • 1
  • 13

0 Answers0