const exec = require('child_process').exec;
const spawn = require('child_process').spawn;

module.exports = {
	name: 'build',
	description: 'Build sources and assets',
	usage: '- wee build [options]',
	options: [
		['-i, --images', 'copy image assets to public directory'],
		['-c, --styles', 'compile and minify Wee stylesheets only'],
		['-s, --scripts', 'compile and minify Wee scripts only']
	],
	action(config, options) {
		// Set Arguments array
		let args = ['run'];
		let option = 'build';

		if (options.images) {
			args.push('build:images');
			option = 'build --images';
		}

		if (options.css) {
			args.push('build:css');
			option = 'build --styles';
		}

		if (options.scripts) {
			args.push('build:js');
			option = 'build --scripts';
		}

		if (! options.scripts && ! options.styles && ! options.images ) {
			args.push('build');
		}

		args.push('--ansi');

		// Execute npm build [options]
		let child = spawn('npm', args, {
			cwd: config.rootPath,
			stdio: 'inherit'
		});

		child.on('error', data => {
			console.log(data);
		});

		child.on('close', (code) => {
			console.log(`Command: wee ` + option + ` was executed!`);
		});

	}
};
@@ -150,13 +150,28 @@
 urce
-s and
+ directory and image
  ass
@@ -336,21 +336,16 @@
 lesheets
- only
 '%5D,%0A%09%09%5B'
@@ -395,13 +395,8 @@
 ipts
- only
 '%5D%0A%09
@@ -819,17 +819,16 @@
 s.images
- 
 ) %7B%0A%09%09%09a
@@ -1147,20 +1147,19 @@
 ted!%60);%0A
+
 %09%09%7D);%0A
-%0A
 %09%7D%0A%7D;

update option descriptions