added bower, gulp
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
# http://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[test/fixtures/*]
|
||||
insert_final_newline = false
|
||||
trim_trailing_whitespace = false
|
||||
+1
@@ -0,0 +1 @@
|
||||
* text=auto
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"node": true,
|
||||
"esnext": true,
|
||||
"bitwise": true,
|
||||
"camelcase": true,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"immed": true,
|
||||
"indent": 4,
|
||||
"latedef": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"quotmark": "double",
|
||||
"regexp": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"strict": true,
|
||||
"trailing": true,
|
||||
"smarttabs": true,
|
||||
"white": true
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
.DS_Store
|
||||
node_modules/
|
||||
temp/
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.9
|
||||
- 0.10
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
|
||||
var gulp = require("gulp"),
|
||||
fs = require("fs"),
|
||||
cp = require("child_process"),
|
||||
jshint = require("gulp-jshint");
|
||||
|
||||
// JSHint
|
||||
// https://github.com/wearefractal/gulp-jshint
|
||||
gulp.task("jshint", function () {
|
||||
|
||||
//
|
||||
// FIXME
|
||||
//
|
||||
// gulp.jshint not reading .jshintrc
|
||||
// side-effect of JSHint itself not read configuration when using stdin
|
||||
//
|
||||
// https://github.com/wearefractal/gulp-jshint/issues/4
|
||||
//
|
||||
|
||||
var options = JSON.parse(fs.readFileSync(".jshintrc", "utf8"));
|
||||
|
||||
//
|
||||
// FIXME
|
||||
//
|
||||
// Can't use following due to Error: EMFILE, too many open files:
|
||||
//
|
||||
// gulp.src("./**/*.js")
|
||||
// .pipe(ignore({
|
||||
// pattern: [
|
||||
// "./node_modules/**",
|
||||
// "./test/temp/**"]}))
|
||||
//
|
||||
// Must wait for core impl of .src() ignores
|
||||
//
|
||||
// https://github.com/wearefractal/gulp/issues/35
|
||||
//
|
||||
|
||||
gulp.src("./*.js")
|
||||
.pipe(jshint(options))
|
||||
.pipe(jshint.reporter("default"));
|
||||
|
||||
gulp.src("./test/**/*.js")
|
||||
.pipe(jshint(options))
|
||||
.pipe(jshint.reporter("default"));
|
||||
});
|
||||
|
||||
// default task
|
||||
gulp.task("default", function () {
|
||||
gulp.run("jshint");
|
||||
|
||||
gulp.watch(["index.js", "./test/**"], function () {
|
||||
gulp.run("jshint");
|
||||
cp.fork("node_modules/.bin/mocha");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
Copyright 2013 Hector Guillermo Parra Alvarez
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
# gulp-rename
|
||||
|
||||
gulp-rename is a [gulp](https://github.com/wearefractal/gulp) plugin to rename files easily.
|
||||
|
||||
## Usage
|
||||
|
||||
gulp-rename provides simple file renaming methods.
|
||||
|
||||
```javascript
|
||||
var rename = require("gulp-rename");
|
||||
|
||||
// rename via string
|
||||
gulp.src("./src/main/text/hello.txt")
|
||||
.pipe(rename("main/text/ciao/goodbye.md"))
|
||||
.pipe(gulp.dest("./dist")); // ./dist/main/text/ciao/goodbye.md
|
||||
|
||||
// rename via function
|
||||
gulp.src("./src/**/hello.txt")
|
||||
.pipe(rename(function (path) {
|
||||
path.dirname += "/ciao";
|
||||
path.basename += "-goodbye";
|
||||
path.extname = ".md"
|
||||
}))
|
||||
.pipe(gulp.dest("./dist")); // ./dist/main/text/ciao/hello-goodbye.md
|
||||
|
||||
// rename via hash
|
||||
gulp.src("./src/main/text/hello.txt", { base: process.cwd() })
|
||||
.pipe(rename({
|
||||
dirname: "main/text/ciao",
|
||||
basename: "aloha",
|
||||
prefix: "bonjour-",
|
||||
suffix: "-hola",
|
||||
extname: ".md"
|
||||
}))
|
||||
.pipe(gulp.dest("./dist")); // ./dist/main/text/ciao/bonjour-aloha-hola.md
|
||||
```
|
||||
|
||||
**See test/rename.spec.js for more examples and test/path-parsing.spec.js for hairy details.**
|
||||
|
||||
## Notes
|
||||
|
||||
* `dirname` is the relative path from the base directory set by `gulp.src` to the filename.
|
||||
* `gulp.src()` uses glob-stream which sets the base to the parent of the first directory glob (`*`, `**`, [], or extglob). `dirname` is the remaining directories or `./` if none. glob-stream versions >= 3.1.0 (used by gulp >= 3.2.2) accept a `base` option, which can be used to explicitly set the base.
|
||||
* `gulp.dest()` renames the directories between `process.cwd()` and `dirname` (i.e. the base relative to CWD). Use `dirname` to rename the directories matched by the glob or descendents of the base of option.
|
||||
* KNOWN ISSUE: The base set when using brace expansion may not be what you expect (See wearefractal/glob2base#1). Use the `base` option described above.
|
||||
* `basename` is the filename without the extension like path.basename(filename, path.extname(filename)).
|
||||
* `extname` is the file extension including the '.' like path.extname(filename).
|
||||
|
||||
## License
|
||||
|
||||
[MIT License](http://en.wikipedia.org/wiki/MIT_License)
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
var map = require("map-stream"),
|
||||
Path = require("path");
|
||||
|
||||
module.exports = function (obj) {
|
||||
"use strict";
|
||||
|
||||
function parsePath(path) {
|
||||
var extname = Path.extname(path);
|
||||
return {
|
||||
dirname: Path.dirname(path),
|
||||
basename: Path.basename(path, extname),
|
||||
extname: extname
|
||||
};
|
||||
}
|
||||
|
||||
function rename(file, callback) {
|
||||
|
||||
var parsedPath = parsePath(file.relative);
|
||||
var path;
|
||||
|
||||
var type = typeof obj;
|
||||
|
||||
if (type === "string" && obj !== "") {
|
||||
|
||||
path = obj;
|
||||
|
||||
} else if (type === "function") {
|
||||
|
||||
var result = obj(parsedPath) || parsedPath;
|
||||
path = Path.join(result.dirname, result.basename + result.extname);
|
||||
|
||||
} else if (type === "object" && obj !== undefined && obj !== null) {
|
||||
|
||||
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;
|
||||
|
||||
path = Path.join(dirname, prefix + basename + suffix + extname);
|
||||
|
||||
} else {
|
||||
callback(new Error("Unsupported renaming parameter type supplied"), undefined);
|
||||
return;
|
||||
}
|
||||
|
||||
file.path = Path.join(file.base, path);
|
||||
|
||||
callback(null, file);
|
||||
}
|
||||
|
||||
return map(rename);
|
||||
};
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "gulp-rename@~1.1.0",
|
||||
"scope": null,
|
||||
"escapedName": "gulp-rename",
|
||||
"name": "gulp-rename",
|
||||
"rawSpec": "~1.1.0",
|
||||
"spec": ">=1.1.0 <1.2.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/mnt/Data/bach/Sites/clameurs.org/sites/all/themes/figureslibres/inifig/node_modules/gulp-jsmin"
|
||||
]
|
||||
],
|
||||
"_from": "gulp-rename@>=1.1.0 <1.2.0",
|
||||
"_id": "gulp-rename@1.1.0",
|
||||
"_inCache": true,
|
||||
"_location": "/gulp-rename",
|
||||
"_npmUser": {
|
||||
"name": "hparra",
|
||||
"email": "hector@hectorparra.com"
|
||||
},
|
||||
"_npmVersion": "1.2.18",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "gulp-rename@~1.1.0",
|
||||
"scope": null,
|
||||
"escapedName": "gulp-rename",
|
||||
"name": "gulp-rename",
|
||||
"rawSpec": "~1.1.0",
|
||||
"spec": ">=1.1.0 <1.2.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/gulp-jsmin"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.1.0.tgz",
|
||||
"_shasum": "93090aaaf4d386c07f20538a6888f15efba727a1",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "gulp-rename@~1.1.0",
|
||||
"_where": "/mnt/Data/bach/Sites/clameurs.org/sites/all/themes/figureslibres/inifig/node_modules/gulp-jsmin",
|
||||
"author": {
|
||||
"name": "Hector Guillermo Parra Alvarez",
|
||||
"email": "hector@hectorparra.com",
|
||||
"url": "https://github.com/hparra"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/hparra/gulp-rename/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"map-stream": ">=0.0.4"
|
||||
},
|
||||
"description": "Rename files",
|
||||
"devDependencies": {
|
||||
"gulp": ">=3.0.0",
|
||||
"gulp-jshint": ">=1.1.0",
|
||||
"mocha": ">=1.15.0",
|
||||
"should": ">=2.1.0"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "93090aaaf4d386c07f20538a6888f15efba727a1",
|
||||
"tarball": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.1.0.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8.0",
|
||||
"npm": ">=1.2.10"
|
||||
},
|
||||
"homepage": "https://github.com/hparra/gulp-rename",
|
||||
"keywords": [
|
||||
"gulpplugin"
|
||||
],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT"
|
||||
}
|
||||
],
|
||||
"main": "./index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "hparra",
|
||||
"email": "hector@hectorparra.com"
|
||||
}
|
||||
],
|
||||
"name": "gulp-rename",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/hparra/gulp-rename.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha test/*.spec.js"
|
||||
},
|
||||
"version": "1.1.0"
|
||||
}
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
Hello
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
Hello
|
||||
Generated
Vendored
+107
@@ -0,0 +1,107 @@
|
||||
/*global describe, context, it, helper */
|
||||
"use strict";
|
||||
|
||||
require("./spec-helper");
|
||||
var Path = require("path");
|
||||
|
||||
describe("gulp-rename path parsing", function () {
|
||||
describe("dirname", function () {
|
||||
context("when src pattern contains no globs", function () {
|
||||
it("dirname is '.'", function (done) {
|
||||
var srcPattern = "test/fixtures/hello.txt";
|
||||
var obj = function (path) {
|
||||
path.dirname.should.equal(".");
|
||||
};
|
||||
helper(srcPattern, obj, null, done);
|
||||
});
|
||||
});
|
||||
|
||||
context("when src pattern contains filename glob", function () {
|
||||
it("dirname is '.'", function (done) {
|
||||
var srcPattern = "test/fixtures/*.min.txt";
|
||||
var obj = function (path) {
|
||||
path.dirname.should.equal(".");
|
||||
};
|
||||
helper(srcPattern, obj, null, done);
|
||||
});
|
||||
});
|
||||
|
||||
var dirname_helper = function (srcPattern, expectedPath) {
|
||||
it("dirname is path from directory glob to file", function (done) {
|
||||
var obj = function (path) {
|
||||
path.dirname.should.match(/^fixtures[0-9]?$/);
|
||||
};
|
||||
helper(srcPattern, obj, null, done);
|
||||
});
|
||||
}
|
||||
|
||||
context("when src pattern matches a directory with *", function () {
|
||||
dirname_helper("test/*/*.min.txt");
|
||||
});
|
||||
|
||||
context("when src pattern matches a directory with **", function () {
|
||||
dirname_helper("test/**/*.min.txt");
|
||||
});
|
||||
|
||||
context("when src pattern matches a directory with [...]", function () {
|
||||
dirname_helper("test/fixt[a-z]res/*.min.txt");
|
||||
});
|
||||
|
||||
/* SKIP: glob2base does not handle brace expansion as expected. See wearefractal/glob2base#1 */
|
||||
context.skip("when src pattern matches a directory with {...,...}", function () {
|
||||
dirname_helper("test/f{ri,ixtur}es/*.min.txt");
|
||||
});
|
||||
|
||||
/* SKIP: glob2base does not handle brace expansion as expected. See wearefractal/glob2base#1 */
|
||||
context.skip("when src pattern matches a directory with {#..#}", function () {
|
||||
dirname_helper("test/fixtures{0..9}/*.min.txt");
|
||||
});
|
||||
|
||||
context("when src pattern matches a directory with an extglob", function () {
|
||||
dirname_helper("test/f+(ri|ixtur)es/*.min.txt");
|
||||
});
|
||||
|
||||
/* requires glob-stream >= 3.1.0 */
|
||||
context.skip("when src pattern includes `base` option", function () {
|
||||
it("dirname is path from given directory to file", function (done) {
|
||||
var srcPattern = "test/**/*.min.txt";
|
||||
var srcOptions = {base: process.cwd()};
|
||||
var obj = function (path) {
|
||||
path.dirname.should.equal("test/fixtures");
|
||||
};
|
||||
helper({pattern: srcPattern, options: srcOptions}, obj, null, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("basename", function () {
|
||||
it("strips extension like Path.basename(path, ext)", function (done) {
|
||||
var srcPattern = "test/fixtures/hello.min.txt";
|
||||
var obj = function (path) {
|
||||
path.basename.should.equal("hello.min");
|
||||
path.basename.should.equal(Path.basename(srcPattern, Path.extname(srcPattern)));
|
||||
};
|
||||
helper(srcPattern, obj, null, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe("extname", function () {
|
||||
it("includes '.' like Path.extname", function (done) {
|
||||
var srcPattern = "test/fixtures/hello.txt";
|
||||
var obj = function (path) {
|
||||
path.extname.should.equal(".txt");
|
||||
path.extname.should.equal(Path.extname(srcPattern));
|
||||
};
|
||||
helper(srcPattern, obj, null, done);
|
||||
});
|
||||
|
||||
it("excludes multiple extensions like Path.extname", function (done) {
|
||||
var srcPattern = "test/fixtures/hello.min.txt";
|
||||
var obj = function (path) {
|
||||
path.extname.should.equal(".txt");
|
||||
path.extname.should.equal(Path.extname(srcPattern));
|
||||
};
|
||||
helper(srcPattern, obj, null, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
Generated
Vendored
+203
@@ -0,0 +1,203 @@
|
||||
/*global describe, context, it, beforeEach, helper, helperError */
|
||||
"use strict";
|
||||
|
||||
require("./spec-helper");
|
||||
|
||||
describe("gulp-rename", function () {
|
||||
context("with string parameter", function () {
|
||||
context("when src pattern does not contain directory glob", function () {
|
||||
it("sets filename to value", function (done) {
|
||||
var srcPattern = "test/fixtures/hello.txt";
|
||||
var obj = "hola.md";
|
||||
var expectedPath = "test/fixtures/hola.md";
|
||||
helper(srcPattern, obj, expectedPath, done);
|
||||
});
|
||||
});
|
||||
context("when src pattern contains directory glob", function () {
|
||||
it("sets relative path to value", function (done) {
|
||||
var srcPattern = "test/**/hello.txt";
|
||||
var obj = "fixtures/hola.md";
|
||||
var expectedPath = "test/fixtures/hola.md";
|
||||
helper(srcPattern, obj, expectedPath, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context("with object parameter", function () {
|
||||
var srcPattern;
|
||||
beforeEach(function () {
|
||||
srcPattern = "test/**/hello.txt";
|
||||
});
|
||||
|
||||
context("with empty object", function () {
|
||||
it("has no effect", function (done) {
|
||||
var obj = {};
|
||||
var expectedPath = "test/fixtures/hello.txt";
|
||||
helper(srcPattern, obj, expectedPath, done);
|
||||
});
|
||||
});
|
||||
|
||||
context("with dirname value", function () {
|
||||
it("replaces dirname with value", function (done) {
|
||||
var obj = {
|
||||
dirname: "elsewhere",
|
||||
};
|
||||
var expectedPath = "test/elsewhere/hello.txt";
|
||||
helper(srcPattern, obj, expectedPath, done);
|
||||
});
|
||||
it("removes dirname with './'", function (done) {
|
||||
var obj = {
|
||||
dirname: "./",
|
||||
};
|
||||
var expectedPath = "test/hello.txt";
|
||||
helper(srcPattern, obj, expectedPath, done);
|
||||
});
|
||||
it("removes dirname with empty string", function (done) {
|
||||
var obj = {
|
||||
dirname: "",
|
||||
};
|
||||
var expectedPath = "test/hello.txt";
|
||||
helper(srcPattern, obj, expectedPath, done);
|
||||
});
|
||||
});
|
||||
|
||||
context("with prefix value", function () {
|
||||
it("prepends value to basename", function (done) {
|
||||
var obj = {
|
||||
prefix: "bonjour-",
|
||||
};
|
||||
var expectedPath = "test/fixtures/bonjour-hello.txt";
|
||||
helper(srcPattern, obj, expectedPath, done);
|
||||
});
|
||||
});
|
||||
|
||||
context("with basename value", function () {
|
||||
it("replaces basename with value", function (done) {
|
||||
var obj = {
|
||||
basename: "aloha",
|
||||
};
|
||||
var expectedPath = "test/fixtures/aloha.txt";
|
||||
helper(srcPattern, obj, expectedPath, done);
|
||||
});
|
||||
it("removes basename with empty string (for consistency)", function (done) {
|
||||
var obj = {
|
||||
prefix: "aloha",
|
||||
basename: "",
|
||||
};
|
||||
var expectedPath = "test/fixtures/aloha.txt";
|
||||
helper(srcPattern, obj, expectedPath, done);
|
||||
});
|
||||
});
|
||||
|
||||
context("with suffix value", function () {
|
||||
it("appends value to basename", function (done) {
|
||||
var obj = {
|
||||
suffix: "-hola",
|
||||
};
|
||||
var expectedPath = "test/fixtures/hello-hola.txt";
|
||||
helper(srcPattern, obj, expectedPath, done);
|
||||
});
|
||||
});
|
||||
|
||||
context("with extname value", function () {
|
||||
it("replaces extname with value", function (done) {
|
||||
var obj = {
|
||||
extname: ".md",
|
||||
};
|
||||
var expectedPath = "test/fixtures/hello.md";
|
||||
helper(srcPattern, obj, expectedPath, done);
|
||||
});
|
||||
it("removes extname with empty string", function (done) {
|
||||
var obj = {
|
||||
extname: "",
|
||||
};
|
||||
var expectedPath = "test/fixtures/hello";
|
||||
helper(srcPattern, obj, expectedPath, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context("with function parameter", function () {
|
||||
var srcPattern;
|
||||
beforeEach(function () {
|
||||
srcPattern = "test/**/hello.txt";
|
||||
});
|
||||
|
||||
it("receives object with dirname", function (done) {
|
||||
var obj = function (path) {
|
||||
path.dirname.should.equal("fixtures");
|
||||
path.dirname = "elsewhere";
|
||||
};
|
||||
var expectedPath = "test/elsewhere/hello.txt";
|
||||
helper(srcPattern, obj, expectedPath, done);
|
||||
});
|
||||
|
||||
it("receives object with basename", function (done) {
|
||||
var obj = function (path) {
|
||||
path.basename.should.equal("hello");
|
||||
path.basename = "aloha";
|
||||
};
|
||||
var expectedPath = "test/fixtures/aloha.txt";
|
||||
helper(srcPattern, obj, expectedPath, done);
|
||||
});
|
||||
|
||||
it("receives object with extname", function (done) {
|
||||
var obj = function (path) {
|
||||
path.extname.should.equal(".txt");
|
||||
path.extname = ".md";
|
||||
};
|
||||
var expectedPath = "test/fixtures/hello.md";
|
||||
helper(srcPattern, obj, expectedPath, done);
|
||||
});
|
||||
|
||||
it("can return a whole new object", function (done) {
|
||||
var obj = function (/*path*/) {
|
||||
return {
|
||||
dirname: "elsewhere",
|
||||
basename: "aloha",
|
||||
extname: ".md"
|
||||
};
|
||||
};
|
||||
var expectedPath = "test/elsewhere/aloha.md";
|
||||
helper(srcPattern, obj, expectedPath, done);
|
||||
});
|
||||
});
|
||||
|
||||
context("throws unsupported parameter type", function () {
|
||||
var srcPattern;
|
||||
beforeEach(function () {
|
||||
srcPattern = "test/**/hello.txt";
|
||||
});
|
||||
|
||||
var UNSUPPORTED_PARAMATER = "Unsupported renaming parameter type supplied";
|
||||
it("with undefined object", function (done) {
|
||||
var obj;
|
||||
var expectedError = UNSUPPORTED_PARAMATER;
|
||||
helperError(srcPattern, obj, expectedError, done);
|
||||
});
|
||||
|
||||
it("with null object", function (done) {
|
||||
var obj = null;
|
||||
var expectedError = UNSUPPORTED_PARAMATER;
|
||||
helperError(srcPattern, obj, expectedError, done);
|
||||
});
|
||||
|
||||
it("with empty string", function (done) {
|
||||
var obj = "";
|
||||
var expectedError = UNSUPPORTED_PARAMATER;
|
||||
helperError(srcPattern, obj, expectedError, done);
|
||||
});
|
||||
|
||||
it("with boolean value", function (done) {
|
||||
var obj = true;
|
||||
var expectedError = UNSUPPORTED_PARAMATER;
|
||||
helperError(srcPattern, obj, expectedError, done);
|
||||
});
|
||||
|
||||
it("with numeric value", function (done) {
|
||||
var obj = 1;
|
||||
var expectedError = UNSUPPORTED_PARAMATER;
|
||||
helperError(srcPattern, obj, expectedError, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
Generated
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
|
||||
require("should");
|
||||
require("mocha");
|
||||
|
||||
var Path = require("path"),
|
||||
gulp = require("gulp"),
|
||||
rename = require("../");
|
||||
|
||||
global.helper = function (srcArgs, obj, expectedPath, done) {
|
||||
var srcPattern = srcArgs.pattern || srcArgs;
|
||||
var srcOptions = srcArgs.options || {};
|
||||
var stream = gulp.src(srcPattern, srcOptions).pipe(rename(obj));
|
||||
var count = 0;
|
||||
stream.on("error", done);
|
||||
stream.on("data", function () {
|
||||
count++;
|
||||
});
|
||||
if (expectedPath) {
|
||||
stream.on("data", function (file) {
|
||||
var resolvedExpectedPath = Path.resolve(expectedPath);
|
||||
var resolvedActualPath = Path.join(file.base, file.relative);
|
||||
resolvedActualPath.should.equal(resolvedExpectedPath);
|
||||
});
|
||||
}
|
||||
stream.on("end", function () {
|
||||
count.should.be.greaterThan(0);
|
||||
done.apply(this, arguments);
|
||||
});
|
||||
};
|
||||
|
||||
global.helperError = function (srcPattern, obj, expectedError, done) {
|
||||
var stream = gulp.src(srcPattern).pipe(rename(obj));
|
||||
stream.on("error", function (err) {
|
||||
err.message.should.equal(expectedError);
|
||||
done();
|
||||
});
|
||||
stream.on("data", function () {});
|
||||
stream.on("end", done);
|
||||
};
|
||||
Reference in New Issue
Block a user