From 36572df982d2b931e0184c32589e4d58ee362b82 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sat, 9 May 2015 17:22:24 -0400 Subject: [PATCH 1/6] generate checksums on startup --- src/nodes/Merger.js | 49 ++++++++++---------- src/nodes/Source.js | 110 +++++++++++++++++++++++++++----------------- 2 files changed, 92 insertions(+), 67 deletions(-) diff --git a/src/nodes/Merger.js b/src/nodes/Merger.js index a74a743..3abf3a4 100644 --- a/src/nodes/Merger.js +++ b/src/nodes/Merger.js @@ -104,35 +104,34 @@ export default class Merger extends Node { let start; let inputdirs = []; - return mapSeries( this.inputs, function ( input, i ) { - if ( aborted ) throw ABORTED; - return input.ready().then( inputdir => inputdirs[i] = inputdir ); - }).then( () => { - start = Date.now(); - - this.emit( 'info', { - code: 'MERGE_START', - id: this.id, - progressIndicator: true - }); - - return mapSeries( inputdirs, inputdir => { + return Promise.all( this.inputs.map( x => x.ready() ) ) + .then( inputdirs => { + start = Date.now(); + + this.emit( 'info', { + code: 'MERGE_START', + id: this.id, + progressIndicator: true + }); + + return mapSeries( inputdirs, inputdir => { + if ( aborted ) throw ABORTED; + return mergeDirectories( inputdir, outputdir ); + }); + }) + .then( () => { if ( aborted ) throw ABORTED; - return mergeDirectories( inputdir, outputdir ); - }); - }).then( () => { - if ( aborted ) throw ABORTED; - this._cleanup( index ); + this._cleanup( index ); - this.emit( 'info', { - code: 'MERGE_COMPLETE', - id: this.id, - duration: Date.now() - start - }); + this.emit( 'info', { + code: 'MERGE_COMPLETE', + id: this.id, + duration: Date.now() - start + }); - return outputdir; - }); + return outputdir; + }); }); } diff --git a/src/nodes/Source.js b/src/nodes/Source.js index 5f96d5b..1066499 100644 --- a/src/nodes/Source.js +++ b/src/nodes/Source.js @@ -1,10 +1,12 @@ import { basename, relative, resolve } from 'path'; -import { link, linkSync, mkdirSync, statSync, Promise } from 'sander'; +import { link, linkSync, lsr, mkdir, mkdirSync, readFileSync, statSync, Promise } from 'sander'; +import { crc32 } from 'crc'; import { watch } from 'graceful-chokidar'; import * as debounce from 'debounce'; import Node from './Node'; import uid from '../utils/uid'; import session from '../session'; +import queue from '../queue'; import GobbleError from '../utils/GobbleError'; export default class Source extends Node { @@ -13,23 +15,22 @@ export default class Source extends Node { this.id = options.id || 'source'; this.dir = dir; - this.callbacks = []; + this.checksumByFile = {}; + this.fileByChecksum = {}; // Ensure the source exists, and is a directory try { const stats = statSync( this.dir ); if ( !stats.isDirectory() ) { + this.isFileSource = true; + this.file = dir; - this.dir = undefined; + this.dir = null; this.uid = uid( this.id ); - - this._ready = new Promise( ( ok, fail ) => { - this._deferred = { ok, fail }; - }); } else { - this._ready = Promise.resolve( this.dir ); + // this._ready = Promise.resolve( this.dir ); } } catch ( err ) { if ( err.code === 'ENOENT' ) { @@ -47,6 +48,39 @@ export default class Source extends Node { } ready () { + if ( !this._ready ) { + this._ready = queue.add( ( fulfil, reject ) => { + const start = Date.now(); + + this.emit( 'info', { + code: 'CHECKSUM_START', + progressIndicator: true, + dir: this.dir + }); + + this._makeReady(); + + lsr( this.dir ) + .then( files => { + files.forEach( file => { + const absolutePath = resolve( this.dir, file ); + const buffer = readFileSync( absolutePath ); + const checksum = crc32( buffer ); + + this.checksumByFile[ absolutePath ] = checksum; + this.fileByChecksum[ checksum ] = absolutePath; + }); + this.emit( 'info', { + code: 'CHECKSUM_COMPLETE', + duration: Date.now() - start, + dir: this.dir + }); + }) + .then( () => fulfil( this.dir ) ) + .catch( reject ); + }); + } + return this._ready; } @@ -55,17 +89,9 @@ export default class Source extends Node { return; } - this._active = true; - - // this is a file watch that isn't fully initialized - if ( this._deferred ) { - this._makeReady(); - } + this._makeReady(); - // make sure the file is in the appropriate target directory to start - if ( this.file ) { - linkSync( this.file ).to( this.targetFile ); - } + this._active = true; let changes = []; @@ -92,20 +118,29 @@ export default class Source extends Node { useFsEvents: false // see https://github.com/paulmillr/chokidar/issues/146 }; - this._watcher = watch( this.dir, options ); + if ( this.isFileSource ) { + this._watcher = watch( this.file, options ); - [ 'add', 'change', 'unlink' ].forEach( type => { - this._watcher.on( type, path => { - changes.push({ type, path }); - relay(); + [ 'add', 'change' ].forEach( type => { + this._watcher.on( type, path => { + linkSync( this.file ).to( this.targetFile ); + changes.push({ type, path: this.targetFile }); + relay(); + }); }); - }); - if ( this.file ) { - this._fileWatcher = watch( this.file, options ); + this._watcher.on( 'unlink', () => { + changes.push({ type: 'unlink', path: this.targetFile }); + unlinkSync( this.targetFile ); + }); + } else { + this._watcher = watch( this.dir, options ); - this._fileWatcher.on( 'change', () => { - link( this.file ).to( this.targetFile ); + [ 'add', 'change', 'unlink' ].forEach( type => { + this._watcher.on( type, path => { + changes.push({ type, path }); + relay(); + }); }); } } @@ -115,10 +150,6 @@ export default class Source extends Node { this._watcher.close(); } - if ( this._fileWatcher ) { - this._fileWatcher.close(); - } - this._active = false; } @@ -136,17 +167,12 @@ export default class Source extends Node { } _makeReady () { - this.dir = resolve( session.config.gobbledir, this.uid ); - this.targetFile = resolve( this.dir, basename( this.file ) ); + if ( this.isFileSource && !this._isReady ) { + this.dir = resolve( session.config.gobbledir, this.uid ); + this.targetFile = resolve( this.dir, basename( this.file ) ); - try { - mkdirSync( this.dir ); - this._deferred.ok( this.dir ); - } catch (e) { - this._deferred.fail( e ); - throw e; + linkSync( this.file ).to( this.targetFile ); + this._isReady = true; // TODO less conflicty flag name } - - delete this._deferred; } } From 90f378c01bdb9e7344cb636fc8b8ea48ee4a4139 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sat, 9 May 2015 17:23:42 -0400 Subject: [PATCH 2/6] fix tests --- test/sourcemaps.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/test/sourcemaps.js b/test/sourcemaps.js index edc7f35..eb8c1c9 100644 --- a/test/sourcemaps.js +++ b/test/sourcemaps.js @@ -145,7 +145,7 @@ module.exports = function () { task.once( 'built', function () { task.once( 'built', function () { - var content = sander.readFileSync( 'tmp/output/baz' ); + var content = sander.readFileSync( 'tmp/output/baz' ).toString(); assert.equal( content, 'step2' ); done(); }); @@ -158,11 +158,7 @@ module.exports = function () { }); }); - task.on( 'error', function ( err ) { - setTimeout( function () { - throw err; - }); - }); + task.on( 'error', done ); }); it( 'does not use non-existent sourcemap files when reusing cached file transformer results', function ( done ) { @@ -272,7 +268,7 @@ module.exports = function () { sander.lsr( 'tmp/output' ) .then( function ( files ) { - assert.deepEqual( files, [ 'app.min.js', 'app.min.js.map' ].sort() ); + assert.deepEqual( files.sort(), [ 'app.min.js', 'app.min.js.map' ].sort() ); }) ]); }); From d2ec0ad9a3856b1be2d362f51092a94a59420169 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sat, 9 May 2015 17:49:02 -0400 Subject: [PATCH 3/6] warn if checksumming takes too long --- src/nodes/Merger.js | 2 +- src/nodes/Source.js | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/nodes/Merger.js b/src/nodes/Merger.js index 3abf3a4..452c4d0 100644 --- a/src/nodes/Merger.js +++ b/src/nodes/Merger.js @@ -104,7 +104,7 @@ export default class Merger extends Node { let start; let inputdirs = []; - return Promise.all( this.inputs.map( x => x.ready() ) ) + return mapSeries( this.inputs, x => x.ready() ) .then( inputdirs => { start = Date.now(); diff --git a/src/nodes/Source.js b/src/nodes/Source.js index 1066499..2f9ae5d 100644 --- a/src/nodes/Source.js +++ b/src/nodes/Source.js @@ -52,12 +52,6 @@ export default class Source extends Node { this._ready = queue.add( ( fulfil, reject ) => { const start = Date.now(); - this.emit( 'info', { - code: 'CHECKSUM_START', - progressIndicator: true, - dir: this.dir - }); - this._makeReady(); lsr( this.dir ) @@ -70,11 +64,12 @@ export default class Source extends Node { this.checksumByFile[ absolutePath ] = checksum; this.fileByChecksum[ checksum ] = absolutePath; }); - this.emit( 'info', { - code: 'CHECKSUM_COMPLETE', - duration: Date.now() - start, - dir: this.dir - }); + + // If + const duration = Date.now() - start; + if ( duration > 200 ) { + this.emit( 'info', `the ${this.dir} directory took ${duration}ms to initialise - consider excluding unnecessary files from the build` ); + } }) .then( () => fulfil( this.dir ) ) .catch( reject ); From dc167dcbfdfce362e3de8506b9e2dc12d918f67e Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sun, 10 May 2015 14:13:18 -0400 Subject: [PATCH 4/6] use checksums to find original sources where possible --- src/nodes/Merger.js | 12 ++++++++- src/nodes/Observer.js | 4 +++ src/nodes/Source.js | 14 +++++++--- src/nodes/Transformer.js | 4 +++ src/nodes/build/index.js | 2 +- src/nodes/serve/handleRequest.js | 4 +-- src/nodes/serve/index.js | 2 +- src/nodes/serve/serveSourcemap.js | 23 +++++++++++++++-- src/nodes/watch/index.js | 2 +- src/utils/flattenSourcemaps.js | 26 ++++++++++++++++--- test/sourcemaps.js | 43 ++++++++++++++++++++++++++++++- 11 files changed, 119 insertions(+), 17 deletions(-) diff --git a/src/nodes/Merger.js b/src/nodes/Merger.js index 452c4d0..f1a6649 100644 --- a/src/nodes/Merger.js +++ b/src/nodes/Merger.js @@ -85,6 +85,17 @@ export default class Merger extends Node { }); } + getFileFromChecksum ( checksum ) { + let i = this.inputs.length; + let file; + + while ( i-- ) { + if ( file = this.inputs[i].getFileFromChecksum( checksum ) ) { + return file; + } + } + } + ready () { let aborted; let index; @@ -102,7 +113,6 @@ export default class Merger extends Node { this._ready = mkdir( outputdir ).then( () => { let start; - let inputdirs = []; return mapSeries( this.inputs, x => x.ready() ) .then( inputdirs => { diff --git a/src/nodes/Observer.js b/src/nodes/Observer.js index e236761..03fe6e5 100644 --- a/src/nodes/Observer.js +++ b/src/nodes/Observer.js @@ -33,6 +33,10 @@ export default class Observer extends Node { this.input.on( 'info', this._oninfo ); } + getFileFromChecksum ( checksum ) { + return this.input.getFileFromChecksum( checksum ); + } + ready () { let observation; diff --git a/src/nodes/Source.js b/src/nodes/Source.js index 2f9ae5d..2a9e4ef 100644 --- a/src/nodes/Source.js +++ b/src/nodes/Source.js @@ -1,5 +1,5 @@ import { basename, relative, resolve } from 'path'; -import { link, linkSync, lsr, mkdir, mkdirSync, readFileSync, statSync, Promise } from 'sander'; +import { linkSync, lsr, readFileSync, statSync, unlinkSync } from 'sander'; import { crc32 } from 'crc'; import { watch } from 'graceful-chokidar'; import * as debounce from 'debounce'; @@ -47,6 +47,10 @@ export default class Source extends Node { this.static = options && options.static; } + getFileFromChecksum ( checksum ) { + return this.fileByChecksum[ checksum ]; + } + ready () { if ( !this._ready ) { this._ready = queue.add( ( fulfil, reject ) => { @@ -65,9 +69,11 @@ export default class Source extends Node { this.fileByChecksum[ checksum ] = absolutePath; }); - // If + // For most situations, generating checksums takes no time at all, + // but it's probably worth warning about this if it becomes a + // source of pain. TODO 'warn' event? const duration = Date.now() - start; - if ( duration > 200 ) { + if ( duration > 1000 ) { this.emit( 'info', `the ${this.dir} directory took ${duration}ms to initialise - consider excluding unnecessary files from the build` ); } }) @@ -117,7 +123,7 @@ export default class Source extends Node { this._watcher = watch( this.file, options ); [ 'add', 'change' ].forEach( type => { - this._watcher.on( type, path => { + this._watcher.on( type, () => { linkSync( this.file ).to( this.targetFile ); changes.push({ type, path: this.targetFile }); relay(); diff --git a/src/nodes/Transformer.js b/src/nodes/Transformer.js index e232ae9..e75241c 100644 --- a/src/nodes/Transformer.js +++ b/src/nodes/Transformer.js @@ -46,6 +46,10 @@ export default class Transformer extends Node { this.input.on( 'info', this._oninfo ); } + getFileFromChecksum ( checksum ) { + return this.input.getFileFromChecksum( checksum ); + } + ready () { let outputdir; let transformation; diff --git a/src/nodes/build/index.js b/src/nodes/build/index.js index 5c8dc58..a3ccdf1 100644 --- a/src/nodes/build/index.js +++ b/src/nodes/build/index.js @@ -35,7 +35,7 @@ export default function ( node, options ) { return node.ready() .then( inputdir => { return copydir( inputdir ).to( dest ) - .then( () => flattenSourcemaps( inputdir, dest, dest, task ) ); + .then( () => flattenSourcemaps( node, inputdir, dest, dest, task ) ); }) .then( () => { node.teardown(); diff --git a/src/nodes/serve/handleRequest.js b/src/nodes/serve/handleRequest.js index 5adecee..c08ab71 100644 --- a/src/nodes/serve/handleRequest.js +++ b/src/nodes/serve/handleRequest.js @@ -6,7 +6,7 @@ import serveDir from './serveDir'; import serveSourcemap from './serveSourcemap'; import serveError from './serveError'; -export default function handleRequest ( srcDir, error, sourcemapPromises, request, response ) { +export default function handleRequest ( node, srcDir, error, sourcemapPromises, request, response ) { const parsedUrl = parse( request.url ); const pathname = parsedUrl.pathname; @@ -31,7 +31,7 @@ export default function handleRequest ( srcDir, error, sourcemapPromises, reques filepath = join( srcDir, pathname ); if ( extname( filepath ) === '.map' ) { - return serveSourcemap( filepath, sourcemapPromises, request, response ) + return serveSourcemap( node, filepath, sourcemapPromises, request, response ) .catch( err => serveError( err, request, response ) ); } diff --git a/src/nodes/serve/index.js b/src/nodes/serve/index.js index 4c0b758..31e03ff 100644 --- a/src/nodes/serve/index.js +++ b/src/nodes/serve/index.js @@ -125,7 +125,7 @@ export default function serve ( node, options = {} ) { }); server.on( 'request', ( request, response ) => { - handleRequest( srcDir, error, sourcemapPromises, request, response ) + handleRequest( node, srcDir, error, sourcemapPromises, request, response ) .catch( err => task.emit( 'error', err ) ); }); diff --git a/src/nodes/serve/serveSourcemap.js b/src/nodes/serve/serveSourcemap.js index 01c8e0f..555c914 100644 --- a/src/nodes/serve/serveSourcemap.js +++ b/src/nodes/serve/serveSourcemap.js @@ -1,6 +1,9 @@ +import { crc32 } from 'crc'; +import { dirname, relative, resolve } from 'path'; +import { readFileSync } from 'sander'; import { load } from 'sorcery'; -export default function serveSourcemap ( filepath, sourcemapPromises, request, response ) { +export default function serveSourcemap ( node, filepath, sourcemapPromises, request, response ) { const owner = filepath.slice( 0, -4 ); if ( !sourcemapPromises[ filepath ] ) { @@ -10,7 +13,23 @@ export default function serveSourcemap ( filepath, sourcemapPromises, request, r throw new Error( 'Could not resolve sourcemap for ' + owner ); } - return chain.apply().toString(); + const map = chain.apply(); + const dir = dirname( owner ); + const cwd = process.cwd(); + + map.sources = map.sources.map( ( source, i ) => { + const content = map.sourcesContent[i]; + const checksum = crc32( content ); + const originalSource = node.getFileFromChecksum( checksum ); + + const absolutePath = resolve( dir, originalSource || source ); + + return relative( cwd, absolutePath ); + }); + + map.sourceRoot = 'file://' + process.cwd(); + + return map.toString(); }); } diff --git a/src/nodes/watch/index.js b/src/nodes/watch/index.js index b4636f1..3017b48 100644 --- a/src/nodes/watch/index.js +++ b/src/nodes/watch/index.js @@ -40,7 +40,7 @@ export default function watch ( node, options ) { progressIndicator: true }); - return flattenSourcemaps( dir, dest, dest, task ).then( () => { + return flattenSourcemaps( node, dir, dest, dest, task ).then( () => { task.emit( 'info', { code: 'SOURCEMAP_PROCESS_COMPLETE', duration: Date.now() - sourcemapProcessStart diff --git a/src/utils/flattenSourcemaps.js b/src/utils/flattenSourcemaps.js index 7282d0d..57972ad 100644 --- a/src/utils/flattenSourcemaps.js +++ b/src/utils/flattenSourcemaps.js @@ -1,11 +1,13 @@ -import { extname, resolve } from 'path'; -import { lsr } from 'sander'; +import { basename, dirname, extname, relative, resolve } from 'path'; +import { lsr, readFileSync, writeFile } from 'sander'; import * as mapSeries from 'promise-map-series'; import { load } from 'sorcery'; +import { crc32 } from 'crc'; +import { SOURCEMAP_COMMENT, getSourcemapComment } from './sourcemap'; const whitelist = { '.js': true, '.css': true }; -export default function flattenSourcemaps ( inputdir, outputdir, base, task ) { +export default function flattenSourcemaps ( node, inputdir, outputdir, base, task ) { return lsr( inputdir ).then( files => { const jsAndCss = files.filter( file => whitelist[ extname( file ) ] ); @@ -13,7 +15,23 @@ export default function flattenSourcemaps ( inputdir, outputdir, base, task ) { return load( resolve( inputdir, file ) ) .then( chain => { if ( chain ) { - return chain.write( resolve( outputdir, file ), { base }); + const map = chain.apply({ base }); + + map.sources = map.sources.map( source => { + const checksum = crc32( readFileSync( base, source ) ); + const originalSource = node.getFileFromChecksum( checksum ); + + const dir = dirname( resolve( base, file ) ); + return originalSource ? relative( dir, originalSource ) : source; + }); + + const code = readFileSync( inputdir, file, { encoding: 'utf-8' }) + .replace( SOURCEMAP_COMMENT, getSourcemapComment( encodeURI( basename( file + '.map' ) ), extname( file ) ) ); + + return Promise.all([ + writeFile( outputdir, file, code ), + writeFile( outputdir, file + '.map', map.toString() ) + ]); } }) .catch( err => { diff --git a/test/sourcemaps.js b/test/sourcemaps.js index eb8c1c9..dd15df1 100644 --- a/test/sourcemaps.js +++ b/test/sourcemaps.js @@ -1,7 +1,7 @@ var assert = require( 'assert' ); var path = require( 'path' ); var request = require( 'request-promise' ); -var gobble = require( '../tmp' ).default; +var gobble = require( '../lib' ).default; var sander = require( 'sander' ); var SourceMapConsumer = require( 'source-map' ).SourceMapConsumer; var simulateChange = require( './utils/simulateChange' ); @@ -387,6 +387,47 @@ module.exports = function () { .catch( done ); }); }); + + it( 'fixes `sources` with original files, where possible', function () { + var source = gobble( 'tmp/sourcemaps' ); + + return source + .include( 'app.coffee' ) + .moveTo( 'js' ) + .transform( 'coffee' ) + .build({ + dest: 'tmp/output' + }) + .then( function () { + return sander.readFile( 'tmp/output/js/app.js.map' ) + .then( String ) + .then( JSON.parse ) + .then( function ( map ) { + assert.deepEqual( map.sources, [ '../../sourcemaps/app.coffee' ]); + }); + }); + }); + + it( 'fixes `sources` with original files when serving', function ( done ) { + var source = gobble( 'tmp/sourcemaps' ); + + task = source + .include( 'app.coffee' ) + .moveTo( 'js' ) + .transform( 'coffee' ) + .serve(); + + task.on( 'error', done ); + + task.once( 'built', function () { + request( 'http://localhost:4567/js/app.js.map' ) + .then( JSON.parse ) + .then( function ( map ) { + assert.deepEqual( map.sources, [ 'tmp/sourcemaps/app.coffee' ]); + done(); + }); + }); + }); }); }; From d9dcd590aac9f41073a7b6a325047d41a97f2b7b Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sun, 10 May 2015 14:16:54 -0400 Subject: [PATCH 5/6] separate building from testing --- package.json | 11 ++++++----- scripts/{test.sh => build.sh} | 7 +++---- test/build.js | 2 +- test/cleanup.js | 2 +- test/env.js | 4 ++-- test/initialisation.js | 2 +- test/sample/foo.js | 2 +- test/scenarios.js | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) rename scripts/{test.sh => build.sh} (80%) diff --git a/package.json b/package.json index 7ed73b2..44ee55d 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "license": "MIT", "repository": "https://github.com/gobblejs/gobble", "dependencies": { - "buffer-crc32": "~0.2.3", "chalk": "^1.0.0", + "crc": "^3.2.1", "debounce": "^1.0.0", "eventemitter2": "^0.4.14", "findup-sync": "~0.1.3", @@ -22,7 +22,7 @@ "resolve": "^1.0.0", "rimraf": "~2.2.8", "sander": "^0.3.2", - "sorcery": "^0.5.4", + "sorcery": "^0.5.5", "source-map-support": "^0.2.10", "tiny-lr": "~0.1.0" }, @@ -43,8 +43,9 @@ "source-map": "^0.4.2" }, "scripts": { - "prepublish": "set -e; npm run build", - "test": "sh ./scripts/test.sh", - "build": "set -e; npm test; rm -rf lib; cp -r tmp lib" + "prepublish": "npm test", + "test": "mocha test/test.js", + "pretest": "npm run build", + "build": "sh ./scripts/build.sh" } } diff --git a/scripts/test.sh b/scripts/build.sh similarity index 80% rename from scripts/test.sh rename to scripts/build.sh index 339f166..7ef9eb5 100644 --- a/scripts/test.sh +++ b/scripts/build.sh @@ -2,6 +2,8 @@ set -e +rm -rf lib + echo "babel..." babel src --out-dir .babel -b es6.modules,useStrict --source-maps-inline --loose es6.classes > /dev/null @@ -9,10 +11,7 @@ echo "esperanto..." esperanto -i .babel -o .esperanto -m inline -t cjs -s echo "sorcery" -sorcery -i .esperanto -o tmp - -echo "mocha..." -mocha test/test.js +sorcery -i .esperanto -o lib rm -rf .babel rm -rf .esperanto \ No newline at end of file diff --git a/test/build.js b/test/build.js index 88fd1e5..6fc835e 100644 --- a/test/build.js +++ b/test/build.js @@ -1,7 +1,7 @@ var assert = require( 'assert' ), path = require( 'path' ), sander = require( 'sander' ), - gobble = require( '../tmp' ).default; + gobble = require( '../lib' ).default; sample = new RegExp( '^' + path.join( __dirname, 'sample' ) ); module.exports = function () { diff --git a/test/cleanup.js b/test/cleanup.js index 6e5983d..df12a90 100644 --- a/test/cleanup.js +++ b/test/cleanup.js @@ -1,7 +1,7 @@ var assert = require( 'assert' ); var path = require( 'path' ); var request = require( 'request-promise' ); -var gobble = require( '../tmp' ).default; +var gobble = require( '../lib' ).default; var sander = require( 'sander' ); var SourceMapConsumer = require( 'source-map' ).SourceMapConsumer; var simulateChange = require( './utils/simulateChange' ); diff --git a/test/env.js b/test/env.js index 116c217..3614fc9 100644 --- a/test/env.js +++ b/test/env.js @@ -1,5 +1,5 @@ var assert = require( 'assert' ), - gobble = require( '../tmp' ).default; + gobble = require( '../lib' ).default; module.exports = function () { describe( 'gobble.env()', function () { @@ -22,7 +22,7 @@ module.exports = function () { process.env.GOBBLE_ENV = 'production'; - gobble = require( '../tmp' ).default; + gobble = require( '../lib' ).default; assert.equal( gobble.env(), 'production' ); Object.keys( require.cache ).forEach( function ( key ) { diff --git a/test/initialisation.js b/test/initialisation.js index 9fe96ae..724d9ab 100644 --- a/test/initialisation.js +++ b/test/initialisation.js @@ -1,7 +1,7 @@ var assert = require( 'assert' ); var path = require( 'path' ); var request = require( 'request-promise' ); -var gobble = require( '../tmp' ).default; +var gobble = require( '../lib' ).default; var sander = require( 'sander' ); var SourceMapConsumer = require( 'source-map' ).SourceMapConsumer; var simulateChange = require( './utils/simulateChange' ); diff --git a/test/sample/foo.js b/test/sample/foo.js index b366756..42d5cbd 100644 --- a/test/sample/foo.js +++ b/test/sample/foo.js @@ -1,4 +1,4 @@ -var gobble = require( '../../tmp' ).default, +var gobble = require( '../../lib' ).default, path = require( 'path' ); module.exports = gobble( path.join( __dirname, 'foo' ) ); diff --git a/test/scenarios.js b/test/scenarios.js index 5572933..c077696 100644 --- a/test/scenarios.js +++ b/test/scenarios.js @@ -1,7 +1,7 @@ var assert = require( 'assert' ); var path = require( 'path' ); var request = require( 'request-promise' ); -var gobble = require( '../tmp' ).default; +var gobble = require( '../lib' ).default; var sander = require( 'sander' ); var SourceMapConsumer = require( 'source-map' ).SourceMapConsumer; var simulateChange = require( './utils/simulateChange' ); From 0cd3caaefe4629dae551ca82bc6bdd4e07263d30 Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Tue, 7 Jun 2016 08:44:54 +0300 Subject: [PATCH 6/6] Fix --- src/nodes/Source.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/nodes/Source.js b/src/nodes/Source.js index f254f11..b0593b5 100644 --- a/src/nodes/Source.js +++ b/src/nodes/Source.js @@ -130,12 +130,6 @@ export default class Source extends Node { relay(); }); }); - } - - this._watcher.on( 'unlink', () => { - changes.push({ type: 'unlink', path: this.targetFile }); - unlinkSync( this.targetFile ); - }); } else { this._watcher = watch( this.dir, options );