From 5710eb78a85e3cde0d04078b1915961d6ef26562 Mon Sep 17 00:00:00 2001 From: Ibby Date: Tue, 11 Oct 2016 20:13:21 -0400 Subject: [PATCH] fix(file): last parameter for writeFile now only accepts options --- src/plugins/file.ts | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/plugins/file.ts b/src/plugins/file.ts index 9cb0675888..e352c5bb5e 100644 --- a/src/plugins/file.ts +++ b/src/plugins/file.ts @@ -659,29 +659,20 @@ export class File { * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above * @param {string} fileName path relative to base path * @param {string | Blob} text content or blob to write - * @param {boolean | WriteOptions} replaceOrOptions replace file if set to true. See WriteOptions for more information. + * @param {WriteOptions} options replace file if set to true. See WriteOptions for more information. * @returns {Promise} Returns a Promise that resolves or rejects with an error. */ static writeFile(path: string, fileName: string, - text: string | Blob, replaceOrOptions: boolean | WriteOptions): Promise { + text: string | Blob, options: WriteOptions): Promise { if ((/^\//.test(fileName))) { let err = new FileError(5); err.message = 'file-name cannot start with \/'; return Promise.reject(err); } - let opts: WriteOptions = {}; - if (replaceOrOptions) { - if (typeof(replaceOrOptions) === 'boolean') { - opts.replace = replaceOrOptions; - } else { - opts.replace = (replaceOrOptions).replace - } - } - let getFileOpts: Flags = { create: true, - exclusive: opts.replace + exclusive: options.replace }; return File.resolveDirectoryUrl(path) @@ -693,12 +684,12 @@ export class File { }) .then((writer) => { - if (opts.append) { + if (options.append) { writer.seek(writer.length); } - if (opts.truncate) { - writer.truncate(opts.truncate); + if (options.truncate) { + writer.truncate(options.truncate); } return File.write(writer, text);