Skip to content

Commit

Permalink
Fix fallback of File#absoluteFileScheme for old Node (#136)
Browse files Browse the repository at this point in the history
* Fix fallback of File#absoluteFileScheme for old Node

* Use file-url module to fallback for generating file scheme

* Update CHANGELOG.md
  • Loading branch information
yhatt authored Aug 20, 2019
1 parent 5f6635a commit 81ba8c0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 5 additions & 4 deletions src/file.ts
Original file line number Diff line number Diff line change
@@ -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<string, any>(mkdirp)
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 81ba8c0

Please sign in to comment.