1
- import * as Command from 'ember-cli/lib/models/command' ;
2
- import * as SilentError from 'silent-error' ;
1
+ const Command = require ( 'ember-cli/lib/models/command' ) ;
2
+ const SilentError = require ( 'silent-error' ) ;
3
+ import denodeify = require( 'denodeify' ) ;
4
+
3
5
import { exec } from 'child_process' ;
4
- import * as Promise from 'ember-cli/lib/ext/promise' ;
5
6
import * as chalk from 'chalk' ;
6
7
import * as fs from 'fs' ;
7
8
import * as fse from 'fs-extra' ;
8
9
import * as path from 'path' ;
9
- import * as WebpackBuild from '../tasks/build-webpack' ;
10
- import * as CreateGithubRepo from '../tasks/create-github-repo' ;
10
+ import WebpackBuild from '../tasks/build-webpack' ;
11
+ import CreateGithubRepo from '../tasks/create-github-repo' ;
11
12
import { CliConfig } from '../models/config' ;
12
13
import { oneLine } from 'common-tags' ;
13
14
14
- const fsReadDir = Promise . denodeify ( fs . readdir ) ;
15
- const fsCopy = Promise . denodeify ( fse . copy ) ;
15
+ const fsReadDir = < any > denodeify ( fs . readdir ) ;
16
+ const fsCopy = < any > denodeify ( fse . copy ) ;
16
17
17
18
interface GithubPagesDeployOptions {
18
19
message ?: string ;
@@ -25,7 +26,7 @@ interface GithubPagesDeployOptions {
25
26
baseHref ?: string ;
26
27
}
27
28
28
- module . exports = Command . extend ( {
29
+ const githubPagesDeployCommand = Command . extend ( {
29
30
name : 'github-pages:deploy' ,
30
31
aliases : [ 'gh-pages:deploy' ] ,
31
32
description : oneLine `
@@ -77,7 +78,7 @@ module.exports = Command.extend({
77
78
aliases : [ 'bh' ]
78
79
} ] ,
79
80
80
- run : function ( options : GithubPagesDeployOptions , rawArgs ) {
81
+ run : function ( options : GithubPagesDeployOptions , rawArgs : string [ ] ) {
81
82
const ui = this . ui ;
82
83
const root = this . project . root ;
83
84
const execOptions = {
@@ -99,10 +100,10 @@ module.exports = Command.extend({
99
100
100
101
let ghPagesBranch = 'gh-pages' ;
101
102
let destinationBranch = options . userPage ? 'master' : ghPagesBranch ;
102
- let initialBranch ;
103
+ let initialBranch : string ;
103
104
104
105
// declared here so that tests can stub exec
105
- const execPromise = Promise . denodeify ( exec ) ;
106
+ const execPromise = < ( cmd : string , options ?: any ) => Promise < string > > denodeify ( exec ) ;
106
107
107
108
const buildTask = new WebpackBuild ( {
108
109
ui : this . ui ,
@@ -155,7 +156,7 @@ module.exports = Command.extend({
155
156
156
157
function checkForPendingChanges ( ) {
157
158
return execPromise ( 'git status --porcelain' )
158
- . then ( stdout => {
159
+ . then ( ( stdout : string ) => {
159
160
if ( / \w + / m. test ( stdout ) ) {
160
161
let msg = 'Uncommitted file changes found! Please commit all changes before deploying.' ;
161
162
return Promise . reject ( new SilentError ( msg ) ) ;
@@ -170,7 +171,7 @@ module.exports = Command.extend({
170
171
171
172
function saveStartingBranchName ( ) {
172
173
return execPromise ( 'git rev-parse --abbrev-ref HEAD' )
173
- . then ( ( stdout ) => initialBranch = stdout . replace ( / \s / g, '' ) ) ;
174
+ . then ( ( stdout : string ) => initialBranch = stdout . replace ( / \s / g, '' ) ) ;
174
175
}
175
176
176
177
function createGitHubRepoIfNeeded ( ) {
@@ -205,7 +206,7 @@ module.exports = Command.extend({
205
206
206
207
function copyFiles ( ) {
207
208
return fsReadDir ( outDir )
208
- . then ( ( files ) => Promise . all ( files . map ( ( file ) => {
209
+ . then ( ( files : string [ ] ) => Promise . all ( files . map ( ( file ) => {
209
210
if ( file === '.gitignore' ) {
210
211
// don't overwrite the .gitignore file
211
212
return Promise . resolve ( ) ;
@@ -245,7 +246,7 @@ module.exports = Command.extend({
245
246
} ) ;
246
247
}
247
248
248
- function failGracefully ( error ) {
249
+ function failGracefully ( error : Error ) {
249
250
if ( error && ( / g i t c l e a n / . test ( error . message ) || / P e r m i s s i o n d e n i e d / . test ( error . message ) ) ) {
250
251
ui . writeLine ( error . message ) ;
251
252
let msg = 'There was a permissions error during git file operations, ' +
@@ -258,3 +259,6 @@ module.exports = Command.extend({
258
259
}
259
260
}
260
261
} ) ;
262
+
263
+
264
+ export default githubPagesDeployCommand ;
0 commit comments