diff options
Diffstat (limited to 'scripts/cpGHPages.ts')
-rw-r--r-- | scripts/cpGHPages.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/cpGHPages.ts b/scripts/cpGHPages.ts new file mode 100644 index 0000000..b820c80 --- /dev/null +++ b/scripts/cpGHPages.ts @@ -0,0 +1,25 @@ +import * as createGit from 'simple-git/promise'; +import { resolve, join } from 'path'; +import { copyFileSync, readdirSync, statSync, unlinkSync } from 'fs'; + +const baseDir = resolve(__dirname, '..'); +const to = (...paths: string[]) => join(baseDir, ...paths); +const git = createGit(); +git.log({ + from: 'HEAD~1', + to: 'HEAD' +}).then(async log => { + const hash = log.latest.hash.slice(0, 7); + await git.checkout('gh-pages'); + for (const f of readdirSync(to('.'))) { + if (statSync(f).isFile()) + unlinkSync(to(f)); + } + const files = readdirSync(to('dist')) + for (const f of files) { + copyFileSync(to('dist', f), to(f)); + } + await git.add(files); + await git.commit('Build demo from ' + hash); + await git.checkout('master'); +});
\ No newline at end of file |