How to use the ensureFile function from fs-promise

Find comprehensive JavaScript fs-promise.ensureFile code examples handpicked from public code repositorys.

108
109
110
111
112
113
114
115
116
117
.then(sortResp)
// Write last read file of each type to a metadata file in the dest
.then((resp) => {
  resp[constants.METADATA] = lastReadFiles(resp)
  const p = options.real && device
    ? fs.ensureFile(device).then(() => fs.writeJson(device, resp[constants.METADATA], {spaces: 0}))
    : Promise.resolve()
  return p.then(() => resp)
})
// Always close the exiftool stream
fork icon1
star icon1
watch icon0

+ 3 other calls in file

36
37
38
39
40
41
42
43
44
45
function save(stream, videoItem) {
    return Promise.resolve()
        .then(() => validateVideo(videoItem))
        .then(() => getFilePath(videoItem))
        .then(filePath => {
            return fs.ensureFile(filePath)
                .then(() => filePath);
        })
        .then(fs.createWriteStream)
        .then(writeStream => pipeStream(stream, writeStream))
fork icon0
star icon0
watch icon0