Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions packages/angular_devkit/schematics_cli/bin/schematics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ import {
SchematicEngine,
UnsuccessfulWorkflowExecution,
} from '@angular-devkit/schematics';
import {
FileSystemEngineHost,
NodeModulesEngineHost,
NodeWorkflow,
} from '@angular-devkit/schematics/tools';
import { NodeModulesEngineHost, NodeWorkflow } from '@angular-devkit/schematics/tools';
import * as minimist from 'minimist';


Expand Down Expand Up @@ -90,7 +86,6 @@ export async function main({

/** Create the DevKit Logger used through the CLI. */
const logger = createConsoleLogger(argv['verbose'], stdout, stderr);

if (argv.help) {
logger.info(getUsage());

Expand All @@ -104,16 +99,18 @@ export async function main({
} = parseSchematicName(argv._.shift() || null);
const isLocalCollection = collectionName.startsWith('.') || collectionName.startsWith('/');


/** If the user wants to list schematics, we simply show all the schematic names. */
if (argv['list-schematics']) {
const engineHost = isLocalCollection
? new FileSystemEngineHost(normalize(process.cwd()))
: new NodeModulesEngineHost();

const engine = new SchematicEngine(engineHost);
const collection = engine.createCollection(collectionName);
logger.info(engine.listSchematicNames(collection).join('\n'));
try {
const engineHost = new NodeModulesEngineHost();
const engine = new SchematicEngine(engineHost);
const collection = engine.createCollection(collectionName);
logger.info(engine.listSchematicNames(collection).join('\n'));
} catch (error) {
logger.fatal(error.message);

return 1;
}

return 0;
}
Expand Down
31 changes: 31 additions & 0 deletions tests/legacy-cli/e2e/tests/schematics_cli/basic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as path from 'path';
import { getGlobalVariable } from '../../utils/env';
import { exec, execAndWaitForOutputToMatch, silentNpm } from '../../utils/process';

const packages = require('../../../../../lib/packages').packages;

export default async function () {
// setup
const argv = getGlobalVariable('argv');
if (argv.noglobal) {
return;
}

const startCwd = process.cwd();
await silentNpm('install', '-g', packages['@angular-devkit/schematics-cli'].tar, '--unsafe-perm');
await exec(process.platform.startsWith('win') ? 'where' : 'which', 'schematics');

// create blank schematic
await exec('schematics', 'schematic', '--name', 'test-schematic');

process.chdir(path.join(startCwd, 'test-schematic'));
await execAndWaitForOutputToMatch(
'schematics',
['.:', '--list-schematics'],
/my-full-schematic/,
);

// restore path
process.chdir(startCwd);

}