Skip to content

Commit

Permalink
references #378, tests for delete file, references #316, convert to JS
Browse files Browse the repository at this point in the history
  • Loading branch information
dbashford committed Feb 3, 2015
1 parent 9876850 commit 29f5e09
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 43 deletions.
44 changes: 25 additions & 19 deletions lib/modules/file/delete.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
"use strict";
var _delete,
__slice = [].slice;

_delete = function(config, options, next) {
var fileName, fs;
fs = require('fs');
if (!options.destinationFile) {
var fs = require( "fs" );

var _delete = function( config, options, next ) {

// has no discernable output file
if ( !options.destinationFile ) {
return next();
}
fileName = options.destinationFile(options.inputFile);
return fs.exists(fileName, function(exists) {
if (!exists) {

var fileName = options.destinationFile( options.inputFile );
fs.exists( fileName, function( exists ) {
if ( !exists ) {
return next();
}
return fs.unlink(fileName, function(err) {
if (err) {
config.log.error("Failed to delete file [[ " + fileName + " ]]");

fs.unlink( fileName, function( err ) {
if ( err ) {
config.log.error( "Failed to delete file [[ " + fileName + " ]]" );
} else {
config.log.success("Deleted file [[ " + fileName + " ]]", options);
config.log.error( "Deleted file [[ " + fileName + " ]]", options );
}
return next();
next();
});
});
};

exports.registration = function(config, register) {
var e;
e = config.extensions;
return register(['remove', 'cleanFile'], 'delete', _delete, __slice.call(e.javascript).concat(__slice.call(e.css), __slice.call(e.copy), __slice.call(e.misc)));
};
exports.registration = function( config, register ) {
var e = config.extensions;
register(
["remove", "cleanFile"],
"delete",
_delete,
[].concat.apply(e.javascript, e.css, e.copy, e.misc)
);
};
24 changes: 0 additions & 24 deletions src/modules/file/delete.coffee

This file was deleted.

37 changes: 37 additions & 0 deletions src/modules/file/delete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"use strict";

var fs = require( "fs" );

var _delete = function( config, options, next ) {

// has no discernable output file
if ( !options.destinationFile ) {
return next();
}

var fileName = options.destinationFile( options.inputFile );
fs.exists( fileName, function( exists ) {
if ( !exists ) {
return next();
}

fs.unlink( fileName, function( err ) {
if ( err ) {
config.log.error( "Failed to delete file [[ " + fileName + " ]]" );
} else {
config.log.success( "Deleted file [[ " + fileName + " ]]", options );
}
next();
});
});
};

exports.registration = function( config, register ) {
var e = config.extensions;
register(
["remove", "cleanFile"],
"delete",
_delete,
[].concat.apply(e.javascript, e.css, e.copy, e.misc)
);
};

0 comments on commit 29f5e09

Please sign in to comment.