Skip to content

Commit

Permalink
Bumping to ECMA version 6, Node 4
Browse files Browse the repository at this point in the history
  • Loading branch information
fboes committed Oct 4, 2017
1 parent 3e5856d commit b14214d
Show file tree
Hide file tree
Showing 56 changed files with 401 additions and 395 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The Blogophon _generator_ works on every platform with [NodeJs](https://nodejs.o
Installation
------------

1. Make sure you have [Node.js](https://nodejs.org/) installed by calling `node -v`.
1. Make sure you have [Node.js](https://nodejs.org/) with at least version 4 installed by calling `node -v`.
1. Make sure you have [ImageMagick](http://www.imagemagick.org/) installed by calling `magick -help`. ImageMagick is needed for scaling images.
1. Run `npm install -g blogophon` to install the Blogophon.
1. Change to a folder you want to initialize a Blogophon blog project in.
Expand Down
16 changes: 8 additions & 8 deletions generate.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env node
'use strict';

var application = require('./src/helpers/application')();
const application = require('./src/helpers/application')();
application.changeDirectory();

var Generator = require('./src/generator');
var args = require('./src/helpers/arguments')();
var config = require('./src/config');
const Generator = require('./src/generator');
const args = require('./src/helpers/arguments')();
const config = require('./src/config');

if (args.help) {
console.log('Usage: node generate.js [OPTIONS]');
Expand All @@ -24,20 +24,20 @@ if (args.help) {
console.log('---- ' + new Date() + ' -----');
}

var generator = Generator(config);
const generator = Generator(config);
generator
.getArticles()
.then(function() {
.then(() => {
return generator.buildAll(args.force || args.f, args.noimages || args.I);
})
.then(function() {
.then(() => {
if(args.deploy || args.d || args.publish) {
generator.deploy();
} else {
console.log('Done');
}
})
.catch(function(err) {
.catch((err) => {
console.error(err); process.exit(1);
})
;
30 changes: 15 additions & 15 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
'use strict';

// Include gulp
var gulp = require('gulp');
var pkg = require('./package.json');
var beep = require('beepbeep');
var onError = function() {
let gulp = require('gulp');
let pkg = require('./package.json');
let beep = require('beepbeep');
let onError = function() {
beep();
return true;
};

// Include Our Plugins
var eslint = require('gulp-eslint');
var nodeunit = require('gulp-nodeunit');
var gls = require('gulp-live-server');
var plumber = require('gulp-plumber');
var sass = require('gulp-sass');
var rename = require("gulp-rename");
var uglify = require('gulp-uglify');
var postcss = require('gulp-postcss');
var replace = require('gulp-replace');
var autoprefixer = require('autoprefixer');
let eslint = require('gulp-eslint');
let nodeunit = require('gulp-nodeunit');
let gls = require('gulp-live-server');
let plumber = require('gulp-plumber');
let sass = require('gulp-sass');
let rename = require("gulp-rename");
let uglify = require('gulp-uglify');
let postcss = require('gulp-postcss');
let replace = require('gulp-replace');
let autoprefixer = require('autoprefixer');

// Lint Task
gulp.task('eslint', function() {
Expand Down Expand Up @@ -102,7 +102,7 @@ gulp.task('build-css', function() {
});

gulp.task('serve', function() {
var server = gls.static(pkg.directories.htdocs);
let server = gls.static(pkg.directories.htdocs);
server.start();
gulp.watch(pkg.directories.htdocs + '/**/*', function(file) {
/* eslint-disable */
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env node
'use strict';

var application = require('./src/helpers/application')();
const application = require('./src/helpers/application')();
application.changeDirectory();

var blogophonConsole = require('./src/blogophon-console');
var args = require('./src/helpers/arguments')();
const blogophonConsole = require('./src/blogophon-console');
const args = require('./src/helpers/arguments')();

if (args.help) {
console.log('Usage: node index.js [OPTIONS]');
Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
"env": {
"node": true
},
"parserOptions": {
"ecmaVersion": 6
},
"globals": {},
"rules": {
"brace-style": 2,
Expand Down Expand Up @@ -133,11 +136,14 @@
"no-multi-str": 2,
"valid-jsdoc": [
1
]
],
"no-var": 2
},
"extends": [
"eslint:recommended"
]
},
"engine": "node >= 0.12.0"
"engine": {
"node": ">=4"
}
}
76 changes: 38 additions & 38 deletions src/blogophon-console.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
'use strict';

var inquirer = require('inquirer');
var fs = require('fs-extra-promise');
var path = require('path');
var shell = require('shelljs');
var config = require('./config');
var Mustache = require('./helpers/blogophon-mustache');
var setup = require('./setup')();
var Generator = require('./generator');
var blogophonDate = require('./models/blogophon-date');
var blogophonEditor = require('./editor')(config);
const inquirer = require('inquirer');
const fs = require('fs-extra-promise');
const path = require('path');
const shell = require('shelljs');
const config = require('./config');
const Mustache = require('./helpers/blogophon-mustache');
const setup = require('./setup')();
const Generator = require('./generator');
const blogophonDate = require('./models/blogophon-date');
const blogophonEditor = require('./editor')(config);

/**
* Represents the Inquirer dialog with which to edit articles.
* @constructor
* @return {Object} [description]
*/
var BlogophonConsole = function() {
var external = {};
var internal = {};
var files = [];
var choicesStr = [
const BlogophonConsole = function() {
const external = {};
const internal = {};
let files = [];
const choicesStr = [
'Create new article',
'Edit existing article',
'Rename article',
Expand All @@ -42,7 +42,7 @@ var BlogophonConsole = function() {
* @return {Array} [description]
*/
internal.makeChoices = function() {
var choices = [];
let choices = [];
if (!config.notInitialized) {
files = blogophonEditor.makeFiles(new inquirer.Separator());
choices.push(choicesStr[0]);
Expand All @@ -66,7 +66,7 @@ var BlogophonConsole = function() {
} else {
console.log(markdownFilename + ' created');
if (templateData.edit) {
var cmd = config.isWin
let cmd = config.isWin
? 'START ' + markdownFilename
: 'open ' + markdownFilename + ' || vi '+ markdownFilename
;
Expand All @@ -85,10 +85,10 @@ var BlogophonConsole = function() {
* @return {[type]} [description]
*/
external.setupDialog = function() {
var themesAvailable= fs.readdirSync(config.directories.theme).filter(function(file) {
let themesAvailable= fs.readdirSync(config.directories.theme).filter(function(file) {
return fs.statSync(path.join(config.directories.theme, file)).isDirectory();
});
var questions = [
let questions = [
{
type: 'input',
name: 'name',
Expand Down Expand Up @@ -256,7 +256,7 @@ var BlogophonConsole = function() {
* @return {[type]} [description]
*/
external.createArticleDialog = function() {
var defaults = {
let defaults = {
classes: 'Normal article',
link: '',
location: '',
Expand Down Expand Up @@ -300,7 +300,7 @@ var BlogophonConsole = function() {
}
};

var questions = [
let questions = [
{
type: 'list',
name: 'classes',
Expand All @@ -318,7 +318,7 @@ var BlogophonConsole = function() {
if (v.trim().length <= 2) {
return 'This title is way too short.';
}
var filename = blogophonEditor.filenameFromTitle(v);
let filename = blogophonEditor.filenameFromTitle(v);
if (fs.existsSync(filename)) {
return ("File " + filename + ' already exists');
}
Expand Down Expand Up @@ -440,9 +440,9 @@ var BlogophonConsole = function() {
function(answers) {
answers.title = answers.title || Math.round(new Date().getTime() / 1000);
answers.date = answers.date || defaults.date;
var markdownFilename = blogophonEditor.filenameFromTitle(blogophonEditor.titleForFilename(answers.title, config, answers.date)) + '.md';
var filename = blogophonEditor.dirnameFromFilename(markdownFilename); // TODO: There is a class for that
var templateData = answers;
let markdownFilename = blogophonEditor.filenameFromTitle(blogophonEditor.titleForFilename(answers.title, config, answers.date)) + '.md';
let filename = blogophonEditor.dirnameFromFilename(markdownFilename); // TODO: There is a class for that
let templateData = answers;
templateData.isMicropost = (answers.classes === 'Micro post');
templateData.lead = templateData.lead || defaults.lead(answers);
templateData.mainText = templateData.mainText || defaults.mainText(answers);
Expand Down Expand Up @@ -473,7 +473,7 @@ var BlogophonConsole = function() {
* @return {void} [description]
*/
external.editArticleDialog = function() {
var questions = [
let questions = [
{
type: 'list',
name: 'file',
Expand All @@ -483,8 +483,8 @@ var BlogophonConsole = function() {
];
inquirer.prompt(questions).then(
function(answers) {
var markdownFilename = path.join(config.directories.data, answers.file);
var cmd = config.isWin ? 'START ' + markdownFilename : 'open ' + markdownFilename + ' || vi '+ markdownFilename;
let markdownFilename = path.join(config.directories.data, answers.file);
let cmd = config.isWin ? 'START ' + markdownFilename : 'open ' + markdownFilename + ' || vi '+ markdownFilename;
console.log('$ ' + cmd);
shell.exec(cmd);
external.init();
Expand All @@ -500,7 +500,7 @@ var BlogophonConsole = function() {
* @return {void} [description]
*/
external.renameArticleDialog = function() {
var questions = [
let questions = [
{
type: 'list',
name: 'file',
Expand All @@ -521,8 +521,8 @@ var BlogophonConsole = function() {
inquirer.prompt(questions).then(
function(answers) {
if (answers.fileNew) {
var processed = 0, maxProcessed = 2;
var checkProcessed = function(err) {
let processed = 0, maxProcessed = 2;
let checkProcessed = function(err) {
if (err) {
console.error(err);
}
Expand Down Expand Up @@ -565,7 +565,7 @@ var BlogophonConsole = function() {
* @return {void} [description]
*/
external.deleteArticleDialog = function() {
var questions = [
let questions = [
{
type: 'list',
name: 'file',
Expand All @@ -581,8 +581,8 @@ var BlogophonConsole = function() {
inquirer.prompt(questions).then(
function(answers) {
if (answers.sure) {
var processed = 0, maxProcessed = 3;
var checkProcessed = function(err) {
let processed = 0, maxProcessed = 3;
let checkProcessed = function(err) {
if (err) {
console.error(err);
}
Expand Down Expand Up @@ -610,7 +610,7 @@ var BlogophonConsole = function() {
* @return {void} [description]
*/
external.generateDialog = function() {
var questions = [
let questions = [
{
type: 'confirm',
name: 'noforce',
Expand All @@ -626,8 +626,8 @@ var BlogophonConsole = function() {
}
}
];
var generator = Generator(config);
var answers;
let generator = Generator(config);
let answers;
inquirer
.prompt(questions)
.then(function(inquirerAnswers) {
Expand Down Expand Up @@ -659,7 +659,7 @@ var BlogophonConsole = function() {
fs.ensureDirSync(config.directories.htdocs);
external.setupDialog();
} else {
var questions = [
let questions = [
{
type: 'list',
name: 'action',
Expand Down
Loading

0 comments on commit b14214d

Please sign in to comment.