Skip to content

Commit

Permalink
fix(tests): Travis rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
pilsy committed Jun 13, 2014
1 parent ff7cbd8 commit 32997f1
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions tests/before_travis_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,57 @@ function installTestModule() {
, source = path.resolve( path.join( __dirname, 'unit', 'test-module' ) )
, dest = path.resolve( path.join( __dirname, '..', 'modules', 'test-module' ) );

console.log( 'step #1 - install test-module and add to bundledDependencies - begin' );
console.log( 'step #2 - install test-module and add to bundledDependencies - begin' );

rimraf( dest, function( e ) {
if ( e === null ) {
ncp( source, dest, function( err ) {
if ( err !== null ) {
console.log( 'Error in step #1 - ' + err + '\n');
console.log( 'Error in step #2 - ' + err + '\n');
reject( e );
} else if ( packageJson.bundledDependencies.indexOf( 'test-module' ) === -1 ) {
packageJson.bundledDependencies.push( 'test-module' );
fs.writeFile( pkgJson, JSON.stringify( packageJson, null, ' ' ), function( e ) {
if ( !!e ) {
console.log( 'Error in step #1 - ' + e + '\n');
console.log( 'Error in step #2 - ' + e + '\n');
reject( e );
} else {
console.log( 'step #1 - completed' );
console.log( 'step #2 - completed' );
resolve();
}
});
} else {
console.log( 'step #1 - completed' );
console.log( 'step #2 - completed' );
resolve();
}
});
} else {
console.log( 'Error in step #1 - ' + e + '\n' );
console.log( 'Error in step #2 - ' + e + '\n' );
reject();
}
});

});
}

function rebaseDb() {
return new Promise( function( resolve, reject ) {
var proc = spawn( 'grunt', [ 'db' ], { stdio: 'inherit', cwd: path.resolve( path.join( __dirname, '..' ) ) } );

console.log( 'step #3 - rebase db' );

proc.stderr.on('data', function (data) {
console.log( 'Error in step #3 - ' + data.toString() + '\n');
reject ( data.toString() );
});

proc.on('close', function (code) {
console.log('step #3 process exited with code ' + code + '\n' );
resolve();
});
});
}

function installORM () {
return new Promise( function( resolve, reject ) {
var objs = [
Expand All @@ -57,7 +75,7 @@ function installORM () {
]
, proc = spawn ( 'clever', [ 'install', 'clever-orm' ], { cwd: path.resolve( path.join( __dirname, '..' ) ) } );

console.log( 'step #2 - install clever-orm module - begin\n' );
console.log( 'step #1 - install clever-orm module - begin\n' );

proc.stdout.on('data', function (data) {
var str = data.toString();
Expand All @@ -75,20 +93,20 @@ function installORM () {
});

proc.stderr.on('data', function (data) {
console.log( 'Error in step #2 - ' + data.toString() + '\n');
console.log( 'Error in step #1 - ' + data.toString() + '\n');
reject ( data.toString() );
});

proc.on('close', function (code) {
console.dir( require( path.resolve( path.join( __dirname, '..', 'package.json' ) ) ) );
console.log('step #2 process exited with code ' + code + '\n' );
console.log('step #1 process exited with code ' + code + '\n' );
resolve();
});
});
}

installTestModule()
.then( installORM )
installORM()
.then( installTestModule )
.then( rebaseDb )
.catch( function (err) {
console.log('Error - ' + err );
});

0 comments on commit 32997f1

Please sign in to comment.