Skip to content

Commit

Permalink
Allow the file to be a FIFO
Browse files Browse the repository at this point in the history
  • Loading branch information
chee committed Feb 21, 2019
1 parent 1db8963 commit 8c8ba53
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions functions/get-input.js
Expand Up @@ -3,24 +3,24 @@ import path from "path"
import fs from "fs"
import {promisify} from "util"

async function checkPathIsRegularFile (path) {
async function checkPathIsReadableFile (path) {
return promisify(fs.stat)(path)
.then(stats => stats.isFile())
.then(stats => stats.isFile() || stats.isFIFO())
.catch(() => false)
}

async function getStream ({file, isTTY}) {
if (file != null && file != "-") {
let filepath = path.resolve(file)
if (!await checkPathIsRegularFile(filepath)) {
if (!await checkPathIsReadableFile(filepath)) {
throw new Error(`not a file: "${filepath}"`)
}
return createReadStream(filepath)
}

let packageLockPath = "package-lock.json"

let packageLockExists = await checkPathIsRegularFile(packageLockPath)
let packageLockExists = await checkPathIsReadableFile(packageLockPath)

if (!file && isTTY && packageLockExists) {
return createReadStream(packageLockPath)
Expand Down

0 comments on commit 8c8ba53

Please sign in to comment.