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+
35import { exec } from 'child_process' ;
4- import * as Promise from 'ember-cli/lib/ext/promise' ;
56import * as chalk from 'chalk' ;
67import * as fs from 'fs' ;
78import * as fse from 'fs-extra' ;
89import * 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' ;
1112import { CliConfig } from '../models/config' ;
1213import { oneLine } from 'common-tags' ;
1314
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 ) ;
1617
1718interface GithubPagesDeployOptions {
1819 message ?: string ;
@@ -25,7 +26,7 @@ interface GithubPagesDeployOptions {
2526 baseHref ?: string ;
2627}
2728
28- module . exports = Command . extend ( {
29+ const githubPagesDeployCommand = Command . extend ( {
2930 name : 'github-pages:deploy' ,
3031 aliases : [ 'gh-pages:deploy' ] ,
3132 description : oneLine `
@@ -77,7 +78,7 @@ module.exports = Command.extend({
7778 aliases : [ 'bh' ]
7879 } ] ,
7980
80- run : function ( options : GithubPagesDeployOptions , rawArgs ) {
81+ run : function ( options : GithubPagesDeployOptions , rawArgs : string [ ] ) {
8182 const ui = this . ui ;
8283 const root = this . project . root ;
8384 const execOptions = {
@@ -99,10 +100,10 @@ module.exports = Command.extend({
99100
100101 let ghPagesBranch = 'gh-pages' ;
101102 let destinationBranch = options . userPage ? 'master' : ghPagesBranch ;
102- let initialBranch ;
103+ let initialBranch : string ;
103104
104105 // 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 ) ;
106107
107108 const buildTask = new WebpackBuild ( {
108109 ui : this . ui ,
@@ -155,7 +156,7 @@ module.exports = Command.extend({
155156
156157 function checkForPendingChanges ( ) {
157158 return execPromise ( 'git status --porcelain' )
158- . then ( stdout => {
159+ . then ( ( stdout : string ) => {
159160 if ( / \w + / m. test ( stdout ) ) {
160161 let msg = 'Uncommitted file changes found! Please commit all changes before deploying.' ;
161162 return Promise . reject ( new SilentError ( msg ) ) ;
@@ -170,7 +171,7 @@ module.exports = Command.extend({
170171
171172 function saveStartingBranchName ( ) {
172173 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, '' ) ) ;
174175 }
175176
176177 function createGitHubRepoIfNeeded ( ) {
@@ -205,7 +206,7 @@ module.exports = Command.extend({
205206
206207 function copyFiles ( ) {
207208 return fsReadDir ( outDir )
208- . then ( ( files ) => Promise . all ( files . map ( ( file ) => {
209+ . then ( ( files : string [ ] ) => Promise . all ( files . map ( ( file ) => {
209210 if ( file === '.gitignore' ) {
210211 // don't overwrite the .gitignore file
211212 return Promise . resolve ( ) ;
@@ -245,7 +246,7 @@ module.exports = Command.extend({
245246 } ) ;
246247 }
247248
248- function failGracefully ( error ) {
249+ function failGracefully ( error : Error ) {
249250 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 ) ) ) {
250251 ui . writeLine ( error . message ) ;
251252 let msg = 'There was a permissions error during git file operations, ' +
@@ -258,3 +259,6 @@ module.exports = Command.extend({
258259 }
259260 }
260261} ) ;
262+
263+
264+ export default githubPagesDeployCommand ;
0 commit comments