Skip to content

Instantly share code, notes, and snippets.

@ccapndave
Last active December 7, 2017 15:16
Show Gist options
  • Save ccapndave/9cb67d14762999f591a9c1ec6843d166 to your computer and use it in GitHub Desktop.
Save ccapndave/9cb67d14762999f591a9c1ec6843d166 to your computer and use it in GitHub Desktop.
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