createFile

Creates a file based on the fileLocationAndName parameter. It resolves the fileLocationAndName string if sucessful or rejects CreatingFileError.
Parameter ListReturnsRejection Errors
  • fileLocationAndName: string
  • content: string
  • tuple: Array (optional)
Promise<string || Array>
Related FunctionsFunction Signature
function createFile(fileLocationAndName, content = ''[, tuple]): Promise<string || Array>
1 2 3 4 import {createFile} from 'puddy-m/lib/fileFunctions' createFile('path/to/file.ext') .then(filePath=>console.log(filePath)) // prints 'path/to/file.ext'
1 2 3 4 import {createFile} from 'puddy-m/lib/fileFunctions' createFile(true) .catch(e=>e) // rejects an instance of CreatingFileError.
1 2 3 4 5 6 // Using it with tuple parameter import {createFile} from 'puddy-m/lib/fileFunctions' createFile('path/to/file1.ext', []) .then(tuple=>validateString('World', tuple)) .then(([first, second])=> first + second) // 'path/to/file1.txtWorld'