Last active
December 7, 2017 15:16
-
-
Save ccapndave/9cb67d14762999f591a9c1ec6843d166 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function writeToV1(path: string): StateTransfomer { | |
return async state => { | |
// Copy all files, making sure that their paths exist | |
await Promise.all( | |
state.files.map(async file => { | |
const fullPath = resolve(path, file.path); | |
await fs.ensureDir(dirname(fullPath)); | |
await fs.writeFile(fullPath, file.buffer); | |
console.log("wrote"); | |
}) | |
); | |
console.log("written"); | |
return state; | |
}; | |
} | |
export function writeToV2(path: string): StateTransfomer { | |
return async state => { | |
// Copy all files, making sure that their paths exist | |
await Promise.all( | |
state.files.map(file => { | |
const fullPath = resolve(path, file.path); | |
return fs.ensureDir(dirname(fullPath)) | |
.then(_ => fs.writeFile(fullPath, file.buffer)) | |
.then(_ => console.log("wrote")); | |
}) | |
); | |
console.log("written"); | |
return state; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment