-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·44 lines (35 loc) · 1.21 KB
/
index.js
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
41
42
43
44
#!/usr/bin/env node
'use strict';
let program = require( 'commander' ),
cwd = process.cwd();
global.INSTALLED_PATH = process.env.DEVTOOLS_GTM_PATH;
global.GULPFILE_PATH = `${ __dirname }/lib`;
global.gulp = require( 'gulp' );
const gutil = require( 'gulp-util' ),
fs = require( 'fs' ),
validate_theme = require( `${ INSTALLED_PATH }/lib/validate_theme` ),
default_error = require( `${ INSTALLED_PATH }/lib/default_error` ),
run = require( `${ INSTALLED_PATH }/lib/run_task` ),
pkg = JSON.parse( fs.readFileSync( `${ INSTALLED_PATH }/package.json`, 'utf-8' ) );
program
.version( pkg.version )
.description( pkg.description )
.usage( '<command>' )
.command( 'init' )
.action( () => {
console.log( '' );
gutil.log( 'You\'re in', gutil.colors.green( cwd ) );
console.log( '' );
gutil.log( gutil.colors.yellow( 'Checking the directory....' ) );
validate_theme( cwd, ( error ) => {
if ( null !== error ) default_error( 'Invalid theme directory!' );
run( 'build', cwd, ( error, result ) => {
if ( null !== error ) default_error( error.message );
if ( result ) gutil.log( result );
} )
} );
} );
program.parse( process.argv );
if ( 0 === process.argv.slice( 2 ).length ) {
program.help();
}