Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-rename

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-rename - npm Package Compare versions

Comparing version 0.1.0 to 0.2.1

.travis.yml

8

Gulpfile.js

@@ -5,2 +5,3 @@ "use strict";

fs = require("fs"),
cp = require("child_process"),
jshint = require("gulp-jshint");

@@ -51,2 +52,9 @@

gulp.run("jshint");
gulp.watch(["index.js", "./test/**"], function () {
gulp.run("jshint");
cp.fork("node_modules/.bin/mocha");
});
});

17

index.js

@@ -14,13 +14,16 @@ var es = require("event-stream"),

// helper variables
var dir = path.dirname(file.path),
ext = path.extname(file.path),
base = path.basename(file.path, ext);
var relativePath = path.relative(file.cwd, file.path),
dir = path.dirname(relativePath),
firstname = file.path.substr(file.path.indexOf(".", 1)),
ext = file.path.substr(file.path.lastIndexOf(".")),
base = path.basename(file.path, ext),
finalName = "";
if (typeof obj === "string") {
file.shortened = obj;
finalName = obj;
} else if (typeof obj === "function") {
file.shortened = obj(dir, base, ext);
finalName = obj(dir, base, ext);

@@ -33,3 +36,3 @@ } else if (typeof obj === "object") {

file.shortened = prefix + base + suffix + extension;
finalName = prefix + path.basename(file.path, firstname) + suffix + extension;

@@ -40,3 +43,3 @@ } else {

file.path = path.join(dir, file.shortened);
file.path = path.join(dir, finalName);
callback(null, file);

@@ -43,0 +46,0 @@ }

@@ -1,5 +0,4 @@

{
"name": "gulp-rename",
"version": "0.1.0",
"version": "0.2.1",
"description": "Rename files",

@@ -28,5 +27,5 @@ "keywords": [

"devDependencies": {
"mocha": "~1.14.0",
"mocha": "~1.15.0",
"should": "~2.1.0",
"gulp": "~2.6.1",
"gulp": "~3.0.0",
"gulp-jshint": "~1.1.0"

@@ -33,0 +32,0 @@ },

@@ -20,3 +20,3 @@ /*global describe, it*/

stream.on("data", function (file) {
String(file.path).should.equal("test/fixtures/hola.md");
String(file.base + file.relative).should.equal("test/fixtures/hola.md");
});

@@ -39,3 +39,3 @@ stream.on("end", function () {

stream.on("data", function (file) {
String(file.path).should.equal("test/fixtures/hello-hola.txt");
String(file.base + file.relative).should.equal("test/fixtures/hello-hola.txt");
});

@@ -60,3 +60,3 @@ stream.on("end", function () {

stream.on("data", function (file) {
String(file.path).should.equal("test/fixtures/bonjour-hello-hola.md");
String(file.base + file.relative).should.equal("test/fixtures/bonjour-hello-hola.md");
});

@@ -77,3 +77,3 @@ stream.on("end", function () {

stream.on("data", function (file) {
String(file.path).should.equal("test/fixtures/hello.txt");
String(file.base + file.relative).should.equal("test/fixtures/hello.txt");
});

@@ -89,3 +89,3 @@ stream.on("end", function () {

var obj = {
ext: ".md"
ext: ".min.md"
};

@@ -97,3 +97,3 @@

stream.on("data", function (file) {
String(file.path).should.equal("test/fixtures/hello.min.md");
String(file.base + file.relative).should.equal("test/fixtures/hello.min.md");
});

@@ -105,22 +105,45 @@ stream.on("end", function () {

// WONTFIX:
// tricky hello.min.txt
// it("should complex rename of files with 'multiple extensions'", function (done) {
//tricky hello.min.txt
it("should complex rename of files with 'multiple extensions'", function (done) {
// var obj = {
// prefix: "bonjour-",
// suffix: "-hola",
// ext: ".md"
// };
var obj = {
prefix: "bonjour-",
suffix: "-hola",
ext: ".min.md"
};
// var stream = gulp.src("./test/fixtures/hello.min.txt").pipe(rename(obj));
var stream = gulp.src("./test/fixtures/hello.min.txt").pipe(rename(obj));
// stream.on("error", done);
// stream.on("data", function (file) {
// String(file.path).should.equal("test/fixtures/bonjour-hello-hola.min.md");
// });
// stream.on("end", function () {
// done();
// });
// });
stream.on("error", done);
stream.on("data", function (file) {
String(file.base + file.relative).should.equal("test/fixtures/bonjour-hello-hola.min.md");
});
stream.on("end", function () {
done();
});
});
// function arguments integrity (identity)
it("should pass correct arguments to renaming function", function (done) {
var path = "test/fixtures/hello.min.txt";
var obj = function (dir, base, ext) {
dir.should.equal("test/fixtures");
base.should.equal("hello.min");
ext.should.equal(".txt");
return base + ext;
};
var stream = gulp.src(path).pipe(rename(obj));
stream.on("error", done);
stream.on("data", function (file) {
String(file.base + file.relative).should.equal(path);
});
stream.on("end", function () {
done();
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc