gulp-rename
    Overview
    Documentation
    Insights
    Code
    Contributors
    Dependencies
    Alternatives

gulp-rename

Rename files

1.4.0  •  Updated 1 years ago  •  by Hayley Parra  •  MIT License

gulp-rename is a gulp plugin to rename files easily.

NPM

build status devDependency Status

Usage

gulp-rename provides simple file renaming methods.

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.
  • 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).
  • when using a function, a second file argument is provided with the whole context and original file value

License

MIT License

How do you feel about the name openbase for this site?

Popularity

Weekly Downloads
748.6K
Stars
653

Maintenance

Development

Last ver 1 year ago
Created 6 years ago
Last commit 2 months ago
24 days between commits

Technology

Node version: 10.6.0
6.1K unpacked

Compliance

MIT License
OSI Approved
0 vulnerabilities

Contributors

25 contributors
Hector G. Parra
Maintainer, 24 commits, 9 merges
Works at uber
contra
Maintainer, 18 commits, 12 merges
Works at staeco
Shinnosuke Watanabe
Maintainer, 5 commits, 5 merges
Douglas Duteil
7 commits, 2 PRs
Simen Bekkhus
7 commits, 4 PRs
Works at folio-as
Robert Juliano
6 commits, 3 PRs

Tags

gulpplugin
Ready for the next level?
Join Devstore's founding team to help us build the ultimate open-source app store, work with the latest technologies, and enjoy great culture, impact and autonomy
© 2020 Devstore, Inc.
Devstore helps developers find and use open-source packages, so they can focus on building amazing things