implement Smartfile.write

This commit is contained in:
2018-02-16 21:57:44 +01:00
parent 9fa98c3804
commit 5b2089044d
17 changed files with 136 additions and 271 deletions

View File

@ -1,4 +1,6 @@
import * as plugins from './smartfile.plugins'
import * as fs from './smartfile.fs'
import * as memory from './smartfile.memory'
export interface ISmartfileConstructorOptions {
path?: string
@ -68,9 +70,12 @@ export class Smartfile {
/**
* write file to disk
* Behaviours:
* - no argument write to exactly where the file was picked up
*/
async write () {
async write (pathArg?: string) {
const stringToWrite = this.contentBuffer.toString()
await memory.toFs(stringToWrite, this.path)
}
/**

View File

@ -1,4 +1,3 @@
import 'typings-global'
export import fs = require('fs')
export import fsExtra = require('fs-extra')
export let glob = require('glob')

View File

@ -42,7 +42,6 @@ export let toString = (fromArg: string) => {
if (res.statusCode === 200) {
done.resolve(res.body)
} else {
console.error('could not get remote file from ' + fromArg)
done.reject(new Error('could not get remote file from ' + fromArg))
}
})