Comparing version 1.0.1 to 1.1.0
18
cli.js
@@ -6,13 +6,11 @@ #!/usr/bin/env node | ||
var cli = meow({ | ||
help: [ | ||
'Usage', | ||
' $ file-url [path]', | ||
'', | ||
'Example', | ||
' $ file-url', | ||
' file:///Users/sindresorhus/dev/file-url' | ||
].join('\n') | ||
}); | ||
var cli = meow([ | ||
'Usage', | ||
' $ file-url [path]', | ||
'', | ||
'Example', | ||
' $ file-url', | ||
' file:///Users/sindresorhus/dev/file-url' | ||
]); | ||
console.log(fileUrl(cli.input[0] || process.cwd())); |
12
index.js
'use strict'; | ||
var path = require('path'); | ||
module.exports = function (str) { | ||
module.exports = function (str, options) { | ||
if (typeof str !== 'string') { | ||
@@ -9,4 +9,12 @@ throw new Error('Expected a string'); | ||
var pathName = path.resolve(str).replace(/\\/g, '/'); | ||
options = options || {}; | ||
var pathName = str; | ||
if (options.resolve !== false) { | ||
pathName = path.resolve(str); | ||
} | ||
pathName = pathName.replace(/\\/g, '/'); | ||
// Windows drive letter must be prefixed with a slash | ||
@@ -13,0 +21,0 @@ if (pathName[0] !== '/') { |
{ | ||
"name": "file-url", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Convert a path to a file url: unicorn.jpg → file:///Users/sindresorhus/unicorn.jpg", | ||
@@ -17,3 +17,3 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "xo && mocha" | ||
}, | ||
@@ -37,7 +37,8 @@ "files": [ | ||
"dependencies": { | ||
"meow": "^3.1.0" | ||
"meow": "^3.7.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*" | ||
"mocha": "*", | ||
"xo": "*" | ||
} | ||
} |
@@ -16,9 +16,13 @@ # file-url [![Build Status](https://travis-ci.org/sindresorhus/file-url.svg?branch=master)](https://travis-ci.org/sindresorhus/file-url) | ||
```js | ||
var fileUrl = require('file-url'); | ||
const fileUrl = require('file-url'); | ||
fileUrl('unicorn.jpg'); | ||
//=> file:///Users/sindresorhus/dev/file-url/unicorn.jpg | ||
//=> 'file:///Users/sindresorhus/dev/file-url/unicorn.jpg' | ||
fileUrl('/Users/pony/pics/unicorn.jpg'); | ||
//=> file:///Users/pony/pics/unicorn.jpg | ||
//=> 'file:///Users/pony/pics/unicorn.jpg' | ||
// passing {resolve: false} will make it not call path.resolve() on the path | ||
fileUrl('unicorn.jpg', {resolve: false}); | ||
//=> 'file:///unicorn.jpg' | ||
``` | ||
@@ -25,0 +29,0 @@ |
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
3511
31
51
2
Updatedmeow@^3.7.0