-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
executable file
·37 lines (33 loc) · 1.26 KB
/
deploy.js
File metadata and controls
executable file
·37 lines (33 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/babel-node
import path from 'path'
import { spawnSync } from 'child_process'
import { makeDir, moveDir, cleanDir } from 'fs'
import {remote, version} from './package.json'
import fetch from 'isomorphic-fetch'
function deploy(){
let options = {
cwd: path.resolve(__dirname)
};
//commit veriosn bump in main repo
spawnSync('git',['reset','HEAD'],options);
spawnSync('git',['add','package.json'],options);
spawnSync('git',['tag',version],options);
spawnSync('git',['commit','-m',`Release:${version}`],options);
spawnSync('git',['push','origin','master','--tags'],options);
options = {
cwd: path.resolve(__dirname, './dist')
};
//push dist folder to deploy repo
console.log('[DEPLOY]: Initialising Repository');
spawnSync('git',['init'],options);
console.log('[DEPLOY]: Adding remote url');
spawnSync('git',['remote','add', remote.name, remote.gitPath],options)
console.log('[DEPLOY]: Add all files');
spawnSync('git',['add','.','--all'],options)
console.log(`[DEPLOY]: Commit with v${version}`);
spawnSync('git', ['commit','-m',`v${version}`], options)
console.log('[DEPLOY]: Push the changes to repo');
let {stdout} = spawnSync('git', ['push', '-f', remote.name, 'master'],options)
console.log(stdout.toString());
}
deploy();