2016-03-12 09:21:16 +00:00
"use strict" ;
2016-05-25 03:23:48 +00:00
require ( "typings-global" ) ;
2016-02-19 23:53:23 +00:00
var plugins = require ( "./npmts.plugins" ) ;
2016-05-17 00:32:40 +00:00
var npmts _promisechain _1 = require ( "./npmts.promisechain" ) ;
2016-04-02 17:22:01 +00:00
exports . isCi = function ( ) {
return plugins . smartci . check . isCi ( ) ;
} ;
2016-03-23 13:12:58 +00:00
exports . isRelease = function ( ) {
2016-03-23 14:47:28 +00:00
return plugins . smartci . check . isCi ( )
&& plugins . smartci . check . isTaggedCommit ( ) ;
} ;
exports . doPublish = function ( ) {
2016-05-26 20:53:59 +00:00
try {
return exports . isRelease ( )
&& plugins . smartci . get . subJobNumber ( ) == 1 ;
}
catch ( err ) {
return false ;
}
2016-03-23 13:12:58 +00:00
} ;
2016-02-19 23:53:23 +00:00
exports . run = function ( configArg ) {
2016-02-22 21:22:39 +00:00
var done = plugins . Q . defer ( ) ;
2016-02-19 23:53:23 +00:00
var config = configArg ;
2016-05-17 00:32:40 +00:00
npmts _promisechain _1 . npmtsOra . text ( "now determining build options..." ) ;
2016-03-23 13:12:58 +00:00
//handle default mode
2016-02-19 23:53:23 +00:00
if ( config . mode == "default" ) {
config . typings = [
2016-03-12 09:21:16 +00:00
"./ts/typings.json"
2016-02-19 23:53:23 +00:00
] ;
config . ts = ( _a = { } ,
_a [ "./ts/**/*.ts" ] = "./dist/" ,
_a [ "./test/test.ts" ] = "./test/" ,
_a
) ;
config . test = [ "./index.js" ] ;
}
2016-04-30 09:55:42 +00:00
//check if config.tsOptions is available
config . tsOptions ? void ( 0 ) : config . tsOptions = { } ;
2016-03-23 13:12:58 +00:00
// handle state of current build
2016-03-23 14:47:28 +00:00
exports . isRelease ( ) ? plugins . beautylog . info ( "All right: This is a RELEASE build!" )
2016-03-23 14:55:07 +00:00
: plugins . beautylog . info ( "NOT A RELEASE build!" ) ;
2016-04-02 17:22:01 +00:00
exports . isRelease ( ) && exports . doPublish ( ) ? plugins . beautylog . info ( "All right: This is the first subBuild, so this one publishes COVERAGE + DOCS when tests succeed!" )
2016-03-23 14:55:07 +00:00
: plugins . beautylog . info ( "We are not publishing anything!" ) ;
2016-03-23 13:12:58 +00:00
// handle coveralls
2016-04-02 17:09:11 +00:00
config . codecov ? void ( 0 ) : config . codecov = true ;
2016-04-02 17:22:01 +00:00
exports . isCi ( ) ? void ( 0 ) : config . codecov = false ;
2016-03-29 23:32:41 +00:00
config . coverageTreshold ? void ( 0 ) : config . coverageTreshold = 70 ;
2016-03-23 14:47:28 +00:00
// handle docs
config . docs ? void ( 0 ) : config . docs = { } ;
config . docs . publish ? void ( 0 ) : config . docs . publish = false ;
exports . doPublish ( ) ? void ( 0 ) : config . docs . publish = false ;
2016-04-01 23:20:52 +00:00
plugins . beautylog . ok ( "build options are ready!" ) ;
2016-03-23 13:12:58 +00:00
done . resolve ( config ) ;
2016-02-19 23:53:23 +00:00
return done . promise ;
var _a ;
} ;