11'use strict' ;
22
33import * as vscode from 'vscode' ;
4- import * as cp from 'child_process' ;
5- import { runInTerminal } from 'run-in-terminal' ;
4+
5+ import { runNgCommand } from './ng/run' ;
6+ import { ngnew } from './ng/new' ;
7+ import { nginit } from './ng/init' ;
8+ import { ngversion } from './ng/version' ;
9+ import { ngserve } from './ng/serve' ;
10+ import { ngdoc } from './ng/doc' ;
11+ import { nglint } from './ng/lint' ;
12+ import { ngcompletion } from './ng/completion' ;
13+ import { nge2e } from './ng/e2e' ;
14+ import { ngformat } from './ng/format' ;
15+ import { ngtest } from './ng/test' ;
16+ import { nggenerate } from './ng/generate' ;
17+ import { nghelp } from './ng/help' ;
18+
19+ // import { ngset } from './ng/set';
20+ // import { ngdeploy } from './ng/deploy';
21+ // import { ngget } from './ng/get';
622
723let outputChannel : vscode . OutputChannel ;
824
@@ -15,99 +31,6 @@ export function activate(context: vscode.ExtensionContext) {
1531
1632function registerCommands ( context : vscode . ExtensionContext ) {
1733
18- let ngnew = vscode . commands . registerCommand ( 'extension.ngNew' , ( ) => {
19- let project = vscode . window . showInputBox ( { placeHolder : 'name of your project' } ) . then (
20- ( data ) => {
21- runNgCommand ( [ 'new' , data ] , true ) ;
22- }
23- )
24- } ) ;
25-
26- let nginit = vscode . commands . registerCommand ( 'extension.ngInit' , ( ) => {
27- let project = vscode . window . showInputBox ( { placeHolder : 'name of your project' } ) . then (
28- ( data ) => {
29- runNgCommand ( [ 'init' , data ] , true ) ;
30- }
31- )
32- } ) ;
33-
34- let ngversion = vscode . commands . registerCommand ( 'extension.ngVersion' , ( ) => {
35- let child = cp . exec ( 'ng version' ) ;
36- child . stdout . on ( 'data' , ( data ) => {
37- console . log ( data ) ;
38- } ) ;
39- } ) ;
40-
41- let ngserve = vscode . commands . registerCommand ( 'extension.ngServe' , ( ) => {
42- runNgCommand ( [ 'serve' ] , true ) ;
43- } ) ;
44-
45- let ngdoc = vscode . commands . registerCommand ( 'extension.ngDoc' , ( ) => {
46- vscode . window . showInputBox ( { placeHolder : 'search for' } ) . then (
47- ( data ) => {
48- runNgCommand ( [ 'doc' , data ] , false ) ;
49- }
50- )
51- } ) ;
52-
53- let nglint = vscode . commands . registerCommand ( 'extension.ngLint' , ( ) => {
54- runNgCommand ( [ 'lint' ] , true ) ;
55- } ) ;
56-
57- let ngcompletion = vscode . commands . registerCommand ( 'extension.ngCompletion' , ( ) => {
58- runNgCommand ( [ 'completion' ] , false ) ;
59- } ) ;
60-
61- let nge2e = vscode . commands . registerCommand ( 'extension.ngE2e' , ( ) => {
62- runNgCommand ( [ 'e2e' ] , true ) ;
63- } ) ;
64-
65- let ngformat = vscode . commands . registerCommand ( 'extension.ngFormat' , ( ) => {
66- runNgCommand ( [ 'format' ] , true ) ;
67- } ) ;
68-
69- let nggenerate = vscode . commands . registerCommand ( 'extension.ngGenerate' , ( ) => {
70- let param : string [ ] = [ 'generate' ]
71- let items = [ 'component' , 'directive' , 'route' , 'pipe' , 'service' ] ;
72- let options = { matchOnDescription : false , placeHolder : "select Type" } ;
73- vscode . window . showQuickPick ( items , options ) . then ( ( data ) => {
74- param . push ( data ) ;
75- vscode . window . showInputBox ( { placeHolder : 'name of the ' + data } ) . then (
76- ( name ) => {
77- param . push ( name ) ;
78- runNgCommand ( param , false ) ;
79- }
80- )
81- } )
82- } ) ;
83-
84- let ngtest = vscode . commands . registerCommand ( 'extension.ngTest' , ( ) => {
85- runNgCommand ( [ 'test' ] , false ) ;
86- } ) ;
87-
88- // let ngget = vscode.commands.registerCommand('extension.ngGet', () => {
89- // child = cp.exec('ng get');
90- // child.stdout.on('data', (data) => {
91- // vscode.window.showInformationMessage(data);
92- // });
93- // });
94-
95- // let ngset = vscode.commands.registerCommand('extension.ngSet', () => {
96- // child = cp.exec('ng set');
97- // child.stdout.on('data', (data) => {
98- // vscode.window.showInformationMessage(data);
99- // });
100- // });
101-
102- // let ngdeploy = vscode.commands.registerCommand('extension.ngDeploy', () => {
103- // child = cp.exec('ng github-pages:deploy');
104- // child.stdout.on('data', (data) => {
105- // vscode.window.showInformationMessage(data);
106- // });
107- // });
108-
109-
110-
11134 context . subscriptions . push ( ngnew ) ;
11235 context . subscriptions . push ( nginit ) ;
11336 context . subscriptions . push ( ngversion ) ;
@@ -119,40 +42,10 @@ function registerCommands(context: vscode.ExtensionContext) {
11942 context . subscriptions . push ( ngcompletion ) ;
12043 context . subscriptions . push ( nggenerate ) ;
12144 context . subscriptions . push ( ngtest ) ;
45+ context . subscriptions . push ( nghelp ) ;
12246
123- // context.subscriptions.push(ngget);
124- // context.subscriptions.push(ngset);
125- // context.subscriptions.push(ngdeploy);
126-
127- }
128-
129- function runCommandInOutputWindow ( args : string [ ] , cwd : string ) {
130- let cmd = 'ng ' + args . join ( ' ' ) ;
131- let p = cp . exec ( cmd , { cwd : cwd , env : process . env } ) ;
132- p . stderr . on ( 'data' , ( data : string ) => {
133- outputChannel . append ( data ) ;
134- } ) ;
135- p . stdout . on ( 'data' , ( data : string ) => {
136- outputChannel . append ( data ) ;
137- } ) ;
138- showOutput ( ) ;
139- }
140-
141- function showOutput ( ) : void {
142- outputChannel . show ( vscode . ViewColumn . Three ) ;
143- }
144-
145- function runNgCommand ( args : string [ ] , useTerminal ?: boolean ) : void {
146-
147- let cwd = vscode . workspace . rootPath ;
148-
149- if ( useTerminal ) {
150- runCommandInTerminal ( args , cwd ) ;
151- } else {
152- runCommandInOutputWindow ( args , cwd ) ;
153- }
154- }
47+ // context.subscriptions.push(ngset);
48+ // context.subscriptions.push(ngget);
49+ // context.subscriptions.push(ngdeploy);
15550
156- function runCommandInTerminal ( args : string [ ] , cwd : string ) : void {
157- runInTerminal ( 'ng' , args , { cwd : cwd , env : process . env } ) ;
15851}
0 commit comments