-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from fs-webdev/from-fs
Merging changes that were made at FamilySearch.
- Loading branch information
Showing
9 changed files
with
138 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "gulp-component-assembler", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"author": "Michael G Collins <[email protected]>", | ||
"contributors": [ | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var gutil = require('gulp-util'); | ||
|
||
function compareLastModifiedTime(stream, cb, basePath, sourceFile, targetPath) { | ||
if (sourceFile.isNull()) { | ||
cb(null, sourceFile); | ||
return; | ||
} | ||
|
||
fs.stat(targetPath, function(err, targetStat) { | ||
if (err) { | ||
if (err.code === 'ENOENT') { | ||
// try reading the file using the oldDest path | ||
var target = path.join(basePath, path.basename(basePath)+'.js'); | ||
|
||
if (target !== targetPath) { | ||
return compareLastModifiedTime(stream, cb, basePath, sourceFile, target); | ||
} | ||
else { | ||
stream.push(sourceFile); | ||
} | ||
} | ||
else { | ||
stream.emit('error', new gutil.PluginError('gulp-changed', err, { | ||
fileName: sourceFile.path | ||
})); | ||
|
||
stream.push(sourceFile); | ||
} | ||
} | ||
|
||
// file changed | ||
else if (sourceFile.stat.mtime > targetStat.mtime) { | ||
stream.push(sourceFile); | ||
} | ||
|
||
cb(); | ||
}); | ||
} | ||
|
||
/** | ||
* Use in conjunction with gulp-changed to properly compare the assembly.json file | ||
* to it's output file. | ||
* @see https://github.com/sindresorhus/gulp-changed#haschanged | ||
*/ | ||
module.exports = function (stream, cb, sourceFile, targetPath) { | ||
var basePath = path.dirname(targetPath); | ||
targetPath = path.join(path.dirname(basePath), path.basename(basePath)+'.js'); | ||
|
||
compareLastModifiedTime(stream, cb, basePath, sourceFile, targetPath); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters