Skip to content
This repository was archived by the owner on Jun 10, 2025. It is now read-only.

fix build hang #56

Merged
merged 1 commit into from
Apr 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/nodes/Merger.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ export default class Merger extends Node {
this._active = false;
}

active () {
return this._active;
}

_cleanup ( index ) {
const dir = join( session.config.gobbledir, this.id );

Expand Down
4 changes: 4 additions & 0 deletions src/nodes/Observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,8 @@ export default class Observer extends Node {
this.input.stop();
this._active = false;
}

active () {
return this._active;
}
}
4 changes: 4 additions & 0 deletions src/nodes/Source.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ export default class Source extends Node {
this._active = false;
}

active () {
return this._active;
}

_findCreator ( filename ) {
try {
statSync( filename );
Expand Down
4 changes: 4 additions & 0 deletions src/nodes/Transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ export default class Transformer extends Node {
this._active = false;
}

active () {
return this._active;
}

_cleanup ( latest ) {
const dir = join( session.config.gobbledir, this.id );

Expand Down
3 changes: 2 additions & 1 deletion src/nodes/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export default function ( node, options ) {
.then(
inputdir => copydir( inputdir ).to( dest ),
err => { throw err; }
);
)
.then(() => node.stop());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d'oh... I added the start, but didn't think to stop it. 👍

}

promise = cleanup( gobbledir )
Expand Down
44 changes: 25 additions & 19 deletions test/build.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,48 @@
var assert = require( 'assert' ),
path = require( 'path' ),
sander = require( 'sander' ),

sample = new RegExp( '^' + path.join( __dirname, 'sample' ) ),
output = path.join( __dirname, 'output' );
gobble = require( '../tmp' ).default;
sample = new RegExp( '^' + path.join( __dirname, 'sample' ) );

module.exports = function () {
describe( 'node.build()', function () {
beforeEach( function () {
// Clean up output dir
return sander.rimraf( 'output' );
return sander.rimraf( 'tmp' ).then( function () {
return sander.copydir( 'sample' ).to( 'tmp' );
});
});

afterEach( function () {
// Clear cache of sample build definitions
Object.keys( require.cache ).forEach( function ( mod ) {
if ( sample.test( mod ) ) {
delete require.cache[ mod ];
}
});

// Clean up output dir
return sander.rimraf( 'output' );
return sander.rimraf( 'tmp' );
});

it( 'should return a promise that fulfils on completion of build', function () {
return require( './sample/foo' ).build({
dest: output
it( 'should return a promise that fulfills on completion of build', function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do'h! Sorry, I have spellcheck on in Sublime :).

return gobble( 'tmp/foo' ).build({
dest: 'tmp/output'
}).then( function () {
return sander.readFile( output, 'foo.md' ).then( function ( data ) {
return sander.readFile( 'tmp/output', 'foo.md' ).then( function ( data ) {
assert.equal( data.toString().trim(), 'foo: this is some text' );
});
});
});

it( 'should stop completion of build', function () {
var node = gobble( 'tmp/foo' );
var task = node.build({
dest: 'tmp/output'
});
return task.then( function () {
assert.equal(node.active(), false);

return sander.readFile( 'tmp/output', 'foo.md' ).then( function ( data ) {
assert.equal( data.toString().trim(), 'foo: this is some text' );
});
});
});

it( 'should throw an error if no `dest` is specified', function () {
assert.throws( function () {
require( './sample/foo' ).build();
gobble( 'tmp/foo' ).build();
}, function ( err ) {
return err.code === 'MISSING_DEST_DIR';
});
Expand Down