replace-ext
Advanced tools
Comparing version 0.0.1 to 1.0.0
19
index.js
@@ -0,9 +1,18 @@ | ||
'use strict'; | ||
var path = require('path'); | ||
module.exports = function(npath, ext) { | ||
if (typeof npath !== 'string') return npath; | ||
if (npath.length === 0) return npath; | ||
function replaceExt(npath, ext) { | ||
if (typeof npath !== 'string') { | ||
return npath; | ||
} | ||
var nFileName = path.basename(npath, path.extname(npath))+ext; | ||
if (npath.length === 0) { | ||
return npath; | ||
} | ||
var nFileName = path.basename(npath, path.extname(npath)) + ext; | ||
return path.join(path.dirname(npath), nFileName); | ||
}; | ||
} | ||
module.exports = replaceExt; |
{ | ||
"name":"replace-ext", | ||
"description":"Replaces a file extension with another one", | ||
"version":"0.0.1", | ||
"homepage":"http://github.com/wearefractal/replace-ext", | ||
"repository":"git://github.com/wearefractal/replace-ext.git", | ||
"author":"Fractal <contact@wearefractal.com> (http://wearefractal.com/)", | ||
"main":"./index.js", | ||
"dependencies":{ | ||
"name": "replace-ext", | ||
"version": "1.0.0", | ||
"description": "Replaces a file extension with another one", | ||
"author": "Gulp Team <team@gulpjs.com> (http://gulpjs.com/)", | ||
"contributors": [ | ||
"Eric Schoffstall <yo@contra.io>", | ||
"Blaine Bublitz <blaine.bublitz@gmail.com>" | ||
], | ||
"repository": "gulpjs/replace-ext", | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">= 0.10" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~1.17.0", | ||
"should": "~3.1.0", | ||
"mocha-lcov-reporter": "~0.0.1", | ||
"coveralls": "~2.6.1", | ||
"istanbul": "~0.2.3", | ||
"rimraf": "~2.2.5", | ||
"jshint": "~2.4.1" | ||
}, | ||
"main": "index.js", | ||
"files": [ | ||
"LICENSE", | ||
"index.js" | ||
], | ||
"scripts": { | ||
"test": "mocha --reporter spec && jshint", | ||
"coveralls": "istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage" | ||
"lint": "eslint . && jscs index.js test/", | ||
"pretest": "npm run lint", | ||
"test": "mocha --async-only", | ||
"cover": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly", | ||
"coveralls": "npm run cover && istanbul-coveralls" | ||
}, | ||
"engines": { | ||
"node": ">= 0.4" | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"eslint": "^1.10.3", | ||
"eslint-config-gulp": "^2.0.0", | ||
"expect": "^1.16.0", | ||
"istanbul": "^0.4.3", | ||
"istanbul-coveralls": "^1.0.3", | ||
"jscs": "^2.3.5", | ||
"jscs-preset-gulp": "^1.0.0", | ||
"mocha": "^2.4.5" | ||
}, | ||
"licenses":[ | ||
{ | ||
"type":"MIT", | ||
"url":"http://github.com/wearefractal/replace-ext/raw/master/LICENSE" | ||
} | ||
"keywords": [ | ||
"gulp", | ||
"extensions", | ||
"filepath", | ||
"basename" | ||
] | ||
} |
@@ -1,44 +0,50 @@ | ||
# replace-ext [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Dependency Status][david-image]][david-url] | ||
<p align="center"> | ||
<a href="http://gulpjs.com"> | ||
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png"> | ||
</a> | ||
</p> | ||
# replace-ext | ||
## Information | ||
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url] | ||
<table> | ||
<tr> | ||
<td>Package</td><td>replace-ext</td> | ||
</tr> | ||
<tr> | ||
<td>Description</td> | ||
<td>Replaces a file extension with another one</td> | ||
</tr> | ||
<tr> | ||
<td>Node Version</td> | ||
<td>>= 0.4</td> | ||
</tr> | ||
</table> | ||
Replaces a file extension with another one. | ||
## Usage | ||
```javascript | ||
```js | ||
var replaceExt = require('replace-ext'); | ||
var path = '/some/dir/file.js'; | ||
var npath = replaceExt(path, '.coffee'); | ||
var newPath = replaceExt(path, '.coffee'); | ||
console.log(npath); // /some/dir/file.coffee | ||
console.log(newPath); // /some/dir/file.coffee | ||
``` | ||
[npm-url]: https://npmjs.org/package/replace-ext | ||
[npm-image]: https://badge.fury.io/js/replace-ext.png | ||
## API | ||
[travis-url]: https://travis-ci.org/wearefractal/replace-ext | ||
[travis-image]: https://travis-ci.org/wearefractal/replace-ext.png?branch=master | ||
### `replaceExt(path, extension)` | ||
[coveralls-url]: https://coveralls.io/r/wearefractal/replace-ext | ||
[coveralls-image]: https://coveralls.io/repos/wearefractal/replace-ext/badge.png | ||
Replaces the extension from `path` with `extension` and returns the updated path string. | ||
[depstat-url]: https://david-dm.org/wearefractal/replace-ext | ||
[depstat-image]: https://david-dm.org/wearefractal/replace-ext.png | ||
Does not replace the extension if `path` is not a string or is empty. | ||
[david-url]: https://david-dm.org/wearefractal/replace-ext | ||
[david-image]: https://david-dm.org/wearefractal/replace-ext.png?theme=shields.io | ||
## License | ||
MIT | ||
[downloads-image]: http://img.shields.io/npm/dm/replace-ext.svg | ||
[npm-url]: https://www.npmjs.com/package/replace-ext | ||
[npm-image]: http://img.shields.io/npm/v/replace-ext.svg | ||
[travis-url]: https://travis-ci.org/gulpjs/replace-ext | ||
[travis-image]: http://img.shields.io/travis/gulpjs/replace-ext.svg?label=travis-ci | ||
[appveyor-url]: https://ci.appveyor.com/project/gulpjs/replace-ext | ||
[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/replace-ext.svg?label=appveyor | ||
[coveralls-url]: https://coveralls.io/r/gulpjs/replace-ext | ||
[coveralls-image]: http://img.shields.io/coveralls/gulpjs/replace-ext/master.svg | ||
[gitter-url]: https://gitter.im/gulpjs/gulp | ||
[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
51
4217
8
4
13
1