rollup-pluginutils
Advanced tools
Comparing version 1.0.1 to 1.1.0
# rollup-pluginutils changelog | ||
## 1.1.0 | ||
* Add `addExtension` function | ||
## 1.0.1 | ||
@@ -4,0 +8,0 @@ |
@@ -35,3 +35,20 @@ 'use strict'; | ||
function basename(path) { | ||
return path.split(/(\/|\\)/).pop(); | ||
} | ||
function extname(path) { | ||
var match = /\.[^\.]+$/.exec(basename(path)); | ||
if (!match) return ''; | ||
return match[0]; | ||
} | ||
function addExtension(filename) { | ||
var ext = arguments.length <= 1 || arguments[1] === undefined ? '.js' : arguments[1]; | ||
if (!extname(filename)) filename += ext; | ||
return filename; | ||
} | ||
exports.createFilter = createFilter; | ||
exports.addExtension = addExtension; | ||
//# sourceMappingURL=pluginutils.cjs.js.map |
@@ -33,3 +33,19 @@ import { resolve } from 'path'; | ||
export { createFilter }; | ||
function basename(path) { | ||
return path.split(/(\/|\\)/).pop(); | ||
} | ||
function extname(path) { | ||
var match = /\.[^\.]+$/.exec(basename(path)); | ||
if (!match) return ''; | ||
return match[0]; | ||
} | ||
function addExtension(filename) { | ||
var ext = arguments.length <= 1 || arguments[1] === undefined ? '.js' : arguments[1]; | ||
if (!extname(filename)) filename += ext; | ||
return filename; | ||
} | ||
export { createFilter, addExtension }; | ||
//# sourceMappingURL=pluginutils.es6.js.map |
{ | ||
"name": "rollup-pluginutils", | ||
"description": "Functionality commonly needed by Rollup plugins", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"main": "dist/pluginutils.cjs.js", | ||
@@ -6,0 +6,0 @@ "jsnext:main": "dist/pluginutils.es6.js", |
@@ -15,6 +15,21 @@ # rollup-pluginutils | ||
### addExtension | ||
```js | ||
import { addExtension } from 'rollup-pluginutils'; | ||
export default function myPlugin ( options = {} ) { | ||
return { | ||
resolveId ( code, id ) { | ||
// only adds an extension if there isn't one already | ||
id = addExtension( id ); // `foo` -> `foo.js`, `foo.js -> foo.js` | ||
id = addExtension( id, '.myext' ); // `foo` -> `foo.myext`, `foo.js -> `foo.js` | ||
} | ||
}; | ||
} | ||
``` | ||
### createFilter | ||
So far, this is the only exported function. | ||
```js | ||
@@ -21,0 +36,0 @@ import { createFilter } from 'rollup-pluginutils'; |
export { default as createFilter } from './createFilter'; | ||
export { default as addExtension } from './addExtension'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
10355
11
118
60