diff --git a/CHANGELOG.md b/CHANGELOG.md index 9002ec8e..b70fa539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Fix an issue `--allow-local-files` may not work in the old Node + Windows ([#133](https://github.com/marp-team/marp-cli/issues/133), [#136](https://github.com/marp-team/marp-cli/pull/136)) + ### Changed - Reconnect to file watcher when disconnected from WebSocket server ([#130](https://github.com/marp-team/marp-cli/pull/130)) diff --git a/package.json b/package.json index a6e62d39..d2be69dd 100644 --- a/package.json +++ b/package.json @@ -129,6 +129,7 @@ "chrome-launcher": "^0.11.1", "cosmiconfig": "^5.2.1", "express": "^4.17.1", + "file-url": "^3.0.0", "get-stdin": "^7.0.0", "globby": "^10.0.1", "import-from": "^3.0.0", diff --git a/src/file.ts b/src/file.ts index 3bb742a3..89a9538a 100644 --- a/src/file.ts +++ b/src/file.ts @@ -1,11 +1,12 @@ import fs from 'fs' +import path from 'path' +import * as url from 'url' +import { promisify } from 'util' +import fileUrl from 'file-url' import getStdin from 'get-stdin' import globby, { GlobbyOptions } from 'globby' import mkdirp from 'mkdirp' -import path from 'path' -import * as url from 'url' import { tmpName } from 'tmp' -import { promisify } from 'util' const stat = promisify(fs.stat) const mkdirpPromise = promisify(mkdirp) @@ -46,7 +47,7 @@ export class File { return url.pathToFileURL(this.absolutePath).toString() // Fallback for Node < v10.12.0 - return `file://${path.posix.resolve(this.path)}` + return fileUrl(this.absolutePath) } convert(output: string | false | undefined, opts: FileConvertOption): File { diff --git a/yarn.lock b/yarn.lock index 7dae6ad3..23b7bdec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2610,6 +2610,11 @@ file-entry-cache@^5.0.1: dependencies: flat-cache "^2.0.1" +file-url@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/file-url/-/file-url-3.0.0.tgz#247a586a746ce9f7a8ed05560290968afc262a77" + integrity sha512-g872QGsHexznxkIAdK8UiZRe7SkE6kvylShU4Nsj8NvfvZag7S0QuQ4IgvPDkk75HxgjIVDwycFTDAgIiO4nDA== + fill-range@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7"