-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(global): use two-space indenting and single quotes (closes #45)
- Loading branch information
Showing
9 changed files
with
433 additions
and
427 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
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,62 +1,65 @@ | ||
var Stream = require("stream"), | ||
Path = require("path"); | ||
'use strict'; | ||
|
||
var Stream = require('stream'); | ||
var Path = require('path'); | ||
|
||
function gulpRename(obj) { | ||
"use strict"; | ||
|
||
var stream = new Stream.Transform({objectMode: true}); | ||
var stream = new Stream.Transform({objectMode: true}); | ||
|
||
function parsePath(path) { | ||
var extname = Path.extname(path); | ||
return { | ||
dirname: Path.dirname(path), | ||
basename: Path.basename(path, extname), | ||
extname: extname | ||
}; | ||
} | ||
|
||
stream._transform = function(file, unused, callback) { | ||
|
||
function parsePath(path) { | ||
var extname = Path.extname(path); | ||
return { | ||
dirname: Path.dirname(path), | ||
basename: Path.basename(path, extname), | ||
extname: extname | ||
}; | ||
} | ||
var parsedPath = parsePath(file.relative); | ||
var path; | ||
|
||
stream._transform = function(file, unused, callback) { | ||
var type = typeof obj; | ||
|
||
var parsedPath = parsePath(file.relative); | ||
var path; | ||
if (type === 'string' && obj !== '') { | ||
|
||
var type = typeof obj; | ||
path = obj; | ||
|
||
if (type === "string" && obj !== "") { | ||
} else if (type === 'function') { | ||
|
||
path = obj; | ||
obj(parsedPath); | ||
path = Path.join(parsedPath.dirname, parsedPath.basename + parsedPath.extname); | ||
|
||
} else if (type === "function") { | ||
} else if (type === 'object' && obj !== undefined && obj !== null) { | ||
|
||
obj(parsedPath); | ||
path = Path.join(parsedPath.dirname, parsedPath.basename + parsedPath.extname); | ||
var dirname = 'dirname' in obj ? obj.dirname : parsedPath.dirname, | ||
prefix = obj.prefix || '', | ||
suffix = obj.suffix || '', | ||
basename = 'basename' in obj ? obj.basename : parsedPath.basename, | ||
extname = 'extname' in obj ? obj.extname : parsedPath.extname; | ||
|
||
} else if (type === "object" && obj !== undefined && obj !== null) { | ||
path = Path.join(dirname, prefix + basename + suffix + extname); | ||
|
||
var dirname = "dirname" in obj ? obj.dirname : parsedPath.dirname, | ||
prefix = obj.prefix || "", | ||
suffix = obj.suffix || "", | ||
basename = "basename" in obj ? obj.basename : parsedPath.basename, | ||
extname = "extname" in obj ? obj.extname : parsedPath.extname; | ||
} else { | ||
|
||
path = Path.join(dirname, prefix + basename + suffix + extname); | ||
callback(new Error('Unsupported renaming parameter type supplied'), undefined); | ||
return; | ||
|
||
} else { | ||
callback(new Error("Unsupported renaming parameter type supplied"), undefined); | ||
return; | ||
} | ||
} | ||
|
||
file.path = Path.join(file.base, path); | ||
file.path = Path.join(file.base, path); | ||
|
||
// Rename sourcemap if present | ||
if (file.sourceMap) { | ||
file.sourceMap.file = file.relative; | ||
} | ||
// Rename sourcemap if present | ||
if (file.sourceMap) { | ||
file.sourceMap.file = file.relative; | ||
} | ||
|
||
callback(null, file); | ||
}; | ||
callback(null, file); | ||
}; | ||
|
||
return stream; | ||
return stream; | ||
} | ||
|
||
module.exports = gulpRename; |
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,4 +1,4 @@ | ||
{ | ||
"extends": "../.jshintrc", | ||
"mocha": true | ||
"extends": "../.jshintrc", | ||
"mocha": true | ||
} |
Oops, something went wrong.