-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsiteglide-cli-sync.js
More file actions
executable file
·40 lines (37 loc) · 1.29 KB
/
siteglide-cli-sync.js
File metadata and controls
executable file
·40 lines (37 loc) · 1.29 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
38
39
40
#!/usr/bin/env node
const program = require('commander'),
spawn = require('child_process').spawn,
command = require('./lib/command'),
fetchAuthData = require('./lib/settings').fetchSettings,
logger = require('./lib/logger'),
version = require('./package.json').version;
program
.version(version, '-v, --version')
.name('siteglide-cli sync')
.usage('<env> [options]')
.description('This command will setup a watcher that will automatically sync up files when you hit save in your IDE.')
.arguments('[environment]', 'Name of environment. Example: staging')
.option('-c --config-file <config-file>', 'config file path', '.siteglide-config')
.option('-l, --livereload', 'Turns on a livereload server')
.action((environment, params) => {
process.env.CONFIG_FILE_PATH = params.configFile;
const authData = fetchAuthData(environment, program);
const env = Object.assign(process.env, {
SITEGLIDE_EMAIL: authData.email,
SITEGLIDE_TOKEN: authData.token,
SITEGLIDE_URL: authData.url
});
const options = [];
if(params.livereload){
options.push('-l');
}
const p = spawn(command('siteglide-cli-watch'), options, {
stdio: 'inherit',
env,
directAssetsUpload: true,
liveReload: params.livereload,
shell: true
});
p.on('error', logger.Error);
});
program.parse(process.argv);