Comparing version 1.1.0 to 2.0.0
14
index.js
'use strict'; | ||
var path = require('path'); | ||
const path = require('path'); | ||
module.exports = function (str, options) { | ||
module.exports = (str, opts) => { | ||
if (typeof str !== 'string') { | ||
@@ -9,7 +9,7 @@ throw new Error('Expected a string'); | ||
options = options || {}; | ||
opts = Object.assign({resolve: true}, opts); | ||
var pathName = str; | ||
let pathName = str; | ||
if (options.resolve !== false) { | ||
if (opts.resolve) { | ||
pathName = path.resolve(str); | ||
@@ -22,6 +22,6 @@ } | ||
if (pathName[0] !== '/') { | ||
pathName = '/' + pathName; | ||
pathName = `/${pathName}`; | ||
} | ||
return encodeURI('file://' + pathName); | ||
return encodeURI(`file://${pathName}`); | ||
}; |
{ | ||
"name": "file-url", | ||
"version": "1.1.0", | ||
"description": "Convert a path to a file url: unicorn.jpg → file:///Users/sindresorhus/unicorn.jpg", | ||
"version": "2.0.0", | ||
"description": "Convert a path to a file url: `unicorn.jpg` → `file:///Users/sindresorhus/unicorn.jpg`", | ||
"license": "MIT", | ||
@@ -12,18 +12,12 @@ "repository": "sindresorhus/file-url", | ||
}, | ||
"bin": "cli.js", | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && mocha" | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"cli.js", | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"cli-app", | ||
"cli", | ||
"bin", | ||
"app", | ||
"file", | ||
@@ -36,9 +30,9 @@ "url", | ||
], | ||
"dependencies": { | ||
"meow": "^3.7.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*", | ||
"ava": "*", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
} |
@@ -30,22 +30,9 @@ # file-url [![Build Status](https://travis-ci.org/sindresorhus/file-url.svg?branch=master)](https://travis-ci.org/sindresorhus/file-url) | ||
## CLI | ||
## Related | ||
``` | ||
$ npm install --global file-url | ||
``` | ||
- [file-url-cli](https://github.com/sindresorhus/file-url-cli) - CLI for this module | ||
``` | ||
$ file-url --help | ||
Usage | ||
$ file-url [path] | ||
Example | ||
$ file-url | ||
file:///Users/sindresorhus/dev/file-url | ||
``` | ||
## License | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
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
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
0
3055
4
18
38
- Removedmeow@^3.7.0
- Removedarray-find-index@1.0.2(transitive)
- Removedcamelcase@2.1.1(transitive)
- Removedcamelcase-keys@2.1.0(transitive)
- Removedcurrently-unhandled@0.4.1(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedfind-up@1.1.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-stdin@4.0.1(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhosted-git-info@2.8.9(transitive)
- Removedindent-string@2.1.0(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedis-finite@1.1.0(transitive)
- Removedis-utf8@0.2.1(transitive)
- Removedload-json-file@1.1.0(transitive)
- Removedloud-rejection@1.6.0(transitive)
- Removedmap-obj@1.0.1(transitive)
- Removedmeow@3.7.0(transitive)
- Removedminimist@1.2.8(transitive)
- Removednormalize-package-data@2.5.0(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedparse-json@2.2.0(transitive)
- Removedpath-exists@2.1.0(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@1.1.0(transitive)
- Removedpify@2.3.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedread-pkg@1.1.0(transitive)
- Removedread-pkg-up@1.0.1(transitive)
- Removedredent@1.0.0(transitive)
- Removedrepeating@2.0.1(transitive)
- Removedresolve@1.22.8(transitive)
- Removedsemver@5.7.2(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.20(transitive)
- Removedstrip-bom@2.0.0(transitive)
- Removedstrip-indent@1.0.1(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedtrim-newlines@1.0.0(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)