1
1
'use strict' ;
2
2
3
- // `require.main.require` so that plugin even works when linked with `npm link`
4
- // see https://github.com/npm/npm/issues/5875 / http://stackoverflow.com/a/25800501
5
- var Command = require . main . require ( '../../ember-cli/lib/models/command' ) ;
6
- var Promise = require . main . require ( '../../ember-cli/lib/ext/promise ') ;
3
+ var path = require ( 'path' ) ,
4
+ fs = require ( 'fs' ) ,
5
+ ghpages = require ( 'gh-pages' ) ,
6
+ denodeify = require ( 'denodeify ') ;
7
7
8
- var path = require ( 'path' ) ;
9
- var fs = require ( 'fs' ) ;
10
- var ghpages = require ( 'gh-pages' ) ;
11
-
12
- module . exports = Command . extend ( {
8
+ module . exports = {
13
9
name : 'ghpages' ,
14
10
aliases : [ 'gh-pages' ] ,
15
11
description : 'Publish to any gh-pages branch on GitHub (or any other branch on any other remote). Build the project before publishing!' ,
@@ -61,7 +57,7 @@ module.exports = Command.extend({
61
57
var ui = this . ui ;
62
58
var root = this . project . root ;
63
59
var dir = path . join ( root , options . dir ) ;
64
-
60
+
65
61
options = options || { } ;
66
62
if ( options [ 'name' ] && options [ 'email' ] ) {
67
63
options . user = {
@@ -72,33 +68,33 @@ module.exports = Command.extend({
72
68
73
69
// gh-pages: forwards messages to ui
74
70
options . logger = function ( message ) { ui . write ( message + "\n" ) ; }
75
-
71
+
76
72
if ( process . env . TRAVIS ) {
77
73
options . message += '\n\n' +
78
74
'Triggered by commit: https://github.com/' + process . env . TRAVIS_REPO_SLUG + '/commit/' + process . env . TRAVIS_COMMIT + '\n' +
79
75
'Travis build: https://travis-ci.org/' + process . env . TRAVIS_REPO_SLUG + '/builds/' + process . env . TRAVIS_BUILD_ID ;
80
76
}
81
-
77
+
82
78
// for your convenience - here you can hack credentials into the repository URL
83
79
if ( process . env . GH_TOKEN && options . repo ) {
84
- options . repo = options . repo . replace ( 'GH_TOKEN' , process . env . GH_TOKEN ) ;
85
- }
80
+ options . repo = options . repo . replace ( 'GH_TOKEN' , process . env . GH_TOKEN ) ;
81
+ }
86
82
87
83
// always clean the cache directory.
88
84
// avoids "Error: Remote url mismatch."
89
85
ghpages . clean ( ) ;
90
86
91
- var access = publish = Promise . denodeify ( fs . access ) ;
92
- var publish = Promise . denodeify ( ghpages . publish ) ;
87
+ var access = publish = denodeify ( fs . access ) ;
88
+ var publish = denodeify ( ghpages . publish ) ;
93
89
94
90
function go ( ) {
95
- return Promise . resolve ( ) ;
96
- }
91
+ return Promise . resolve ( ) ;
92
+ }
97
93
98
94
return go ( )
99
95
. then ( function ( ) {
100
96
return access ( dir , fs . F_OK )
101
- } )
97
+ } )
102
98
. catch ( function ( error ) {
103
99
ui . writeError ( 'Dist folder does not exist. Check the dir --dir parameter or build the project first!\n' ) ;
104
100
return Promise . reject ( error ) ;
@@ -114,4 +110,4 @@ module.exports = Command.extend({
114
110
return Promise . reject ( error ) ;
115
111
} ) ;
116
112
}
117
- } ) ;
113
+ } ;
0 commit comments