Commit d0ddead4 authored by Fabrice Marsaud's avatar Fabrice Marsaud Committed by GitHub

Merge pull request #9 from Wescoeur/prevent-overwrite

createWriteStream supports 'wx'/'w+x' flags.
parents 64ab18d1 2e58e126
...@@ -6,7 +6,8 @@ import {Writable} from 'stream' ...@@ -6,7 +6,8 @@ import {Writable} from 'stream'
import { import {
FILE_OPEN, FILE_OPEN,
FILE_OPEN_IF, FILE_OPEN_IF,
FILE_OVERWRITE_IF FILE_OVERWRITE_IF,
FILE_CREATE
} from '../structures/constants' } from '../structures/constants'
const requestAsync = Bluebird.promisify(request) const requestAsync = Bluebird.promisify(request)
...@@ -102,6 +103,8 @@ export default function (path, options, cb) { ...@@ -102,6 +103,8 @@ export default function (path, options, cb) {
createDisposition = FILE_OPEN_IF createDisposition = FILE_OPEN_IF
} else if (flags === 'w' || flags === 'w+') { } else if (flags === 'w' || flags === 'w+') {
createDisposition = FILE_OVERWRITE_IF createDisposition = FILE_OVERWRITE_IF
} else if (flags === 'wx' || flags === 'w+x') {
createDisposition = FILE_CREATE
} }
request('create', { path, createDisposition }, this, (err, file) => { request('create', { path, createDisposition }, this, (err, file) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment