File tree 5 files changed +51
-2
lines changed
5 files changed +51
-2
lines changed Original file line number Diff line number Diff line change
1
+ Language : JavaScript
2
+ BasedOnStyle : Google
3
+ ColumnLimit : 100
Original file line number Diff line number Diff line change 10
10
},
11
11
"scripts" : {
12
12
"start" : " ng server" ,
13
- "postinstall" : " typings install --ambient"
13
+ "postinstall" : " typings install --ambient" ,
14
+ "format" : " clang-format -i -style=file --glob=src/**/*.ts"
14
15
},
15
16
"private" : true ,
16
17
"dependencies" : {
17
18
"angular2" : " 2.0.0-beta.6" ,
19
+ "clang-format" : " ^1.0.35" ,
18
20
"es6-promise" : " ^3.0.2" ,
19
21
"es6-shim" : " ^0.33.3" ,
20
22
"reflect-metadata" : " 0.1.2" ,
Original file line number Diff line number Diff line change
1
+ /* jshint node: true */
2
+ 'use strict' ;
3
+
4
+ var Command = require ( 'ember-cli/lib/models/command' ) ;
5
+ var FormatTask = require ( '../tasks/format' ) ;
6
+
7
+ module . exports = Command . extend ( {
8
+ name : 'format' ,
9
+ description : 'Formats code in existing project' ,
10
+ works : 'insideProject' ,
11
+ run : function ( ) {
12
+ var formatTask = new FormatTask ( {
13
+ ui : this . ui ,
14
+ analytics : this . analytics ,
15
+ project : this . project
16
+ } ) ;
17
+
18
+ return formatTask . run ( ) ;
19
+ }
20
+ } ) ;
Original file line number Diff line number Diff line change @@ -8,7 +8,8 @@ module.exports = {
8
8
'new' : require ( './commands/new' ) ,
9
9
'init' : require ( './commands/init' ) ,
10
10
'install' : require ( './commands/install' ) ,
11
- 'uninstall' : require ( './commands/uninstall' )
11
+ 'uninstall' : require ( './commands/uninstall' ) ,
12
+ 'format' : require ( './commands/format' )
12
13
} ;
13
14
}
14
15
} ;
Original file line number Diff line number Diff line change
1
+ /* jshint node: true */
2
+ 'use strict' ;
3
+
4
+ var Promise = require ( 'ember-cli/lib/ext/promise' ) ;
5
+ var Task = require ( 'ember-cli/lib/models/task' ) ;
6
+ var exec = Promise . denodeify ( require ( 'child_process' ) . exec ) ;
7
+
8
+ module . exports = Task . extend ( {
9
+ run : function ( ) {
10
+ var chalk = require ( 'chalk' ) ;
11
+ var ui = this . ui ;
12
+
13
+ return exec ( 'npm run format' )
14
+ . then ( function ( ) {
15
+ ui . writeLine ( chalk . green ( 'Successfully formatted files.' ) ) ;
16
+ } )
17
+ . catch ( function ( /*error*/ ) {
18
+ ui . writeLine ( chalk . red (
19
+ 'Couldn\'t do \'npm run format\'. Please check this script exists in your package.json.'
20
+ ) ) ;
21
+ } ) ;
22
+ }
23
+ } ) ;
You can’t perform that action at this time.
0 commit comments