Skip to content

Commit 7979276

Browse files
author
Jaydson
committed
Using ES6 features
1 parent 0197de5 commit 7979276

File tree

7 files changed

+234
-226
lines changed

7 files changed

+234
-226
lines changed

src/bin/cli/logo.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
var localconfig = require('../config'),
2-
helpers = require('../helpers'),
3-
clc = helpers.cliColor(),
4-
logo = '\n' +
1+
import { version } from '../config';
2+
import { cliColor } from '../helpers';
3+
4+
var clc = cliColor(),
5+
logo = clc.message('\n' +
56
'|_| _ _ _ _ _ _ . _ \n' +
67
'| |(_|| | | |(_)| ||(_ \n' +
7-
' ' + localconfig.version + ' \n';
8+
' ' + version + ' \n');
89

9-
module.exports = clc.message(logo);
10+
export default logo;

src/bin/cli/program.js

+21-23
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,67 @@
11
require('grunt-6to5/node_modules/6to5/polyfill');
2+
var program = require('commander');
23

3-
var localconfig = require('../config'),
4-
helpers = require('../helpers'),
5-
program = require('commander'),
6-
logo = require('../cli/logo');
4+
import { version } from '../config';
5+
import { cliColor } from '../helpers';
6+
import logo from './logo';
7+
import { init, config, newFile, run } from './util';
78

89
program
9-
.version(localconfig.version);
10+
.version(version);
1011

1112
program
1213
.command('init')
1314
.description('Init your static website')
14-
.action(function(path) {
15-
var util = require('../cli/util');
15+
.action((path) => {
1616
console.log(logo);
17-
util.init(typeof path === 'string' ? path : './');
17+
init(typeof path === 'string' ? path : './');
1818
});
1919

2020
program
2121
.command('config')
2222
.description('Config your static website')
23-
.action(function() {
24-
var util = require('../cli/util');
23+
.action(() => {
2524
console.log(logo);
26-
util.config();
25+
config();
2726
});
2827

2928
program
3029
.command('build')
3130
.description('Build your static website')
32-
.action(function() {
33-
var core = require('../core');
31+
.action(() => {
32+
let core = require('../core');
3433
core.init();
3534
});
3635

3736
program
3837
.command('new_post ["title"]')
3938
.description('Create a new post')
40-
.action(function(title) {
41-
require('../cli/util').newFile('post', title);
39+
.action((title) => {
40+
newFile('post', title);
4241
});
4342

4443
program
4544
.command('new_page ["title"]')
4645
.description('Create a new page')
47-
.action(function(title) {
48-
require('../cli/util').newFile('page', title);
46+
.action((title) => {
47+
newFile('page', title);
4948
});
5049

5150
program
5251
.command('run [port]')
5352
.description('Run you static site locally. Port is optional')
54-
.action(function(port = 9356) {
55-
var util = require('../cli/util'),
56-
core = require('../core'),
53+
.action(function(port = 9356) { // We're not using arrow function here due to an jshint issue
54+
let core = require('../core'),
5755
build = core.init();
5856
if (build) {
5957
build.then(function() {
60-
util.run(port);
58+
run(port);
6159
});
6260
}
6361
});
6462

65-
program.on('*', function(args) {
66-
var clc = helpers.cliColor();
63+
program.on('*', (args) => {
64+
let clc = cliColor();
6765
console.error('Unknown command: ' + clc.error(args[0]));
6866
process.exit(1);
6967
});

0 commit comments

Comments
 (0)