diff --git a/.editorconfig b/.editorconfig
index 532d98c2d7d7e..e2dcf6cd2bcc7 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -9,6 +9,9 @@ end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
+[*.js]
+indent_size = 2
+
[*.md]
trim_trailing_whitespace = false
diff --git a/.eslintrc b/.eslintrc
deleted file mode 100644
index 19f15ed044e14..0000000000000
--- a/.eslintrc
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "parser": "babel-eslint",
- "env": {
- "node": true
- },
- "rules": {
- "complexity": [1, 8],
- "consistent-return": 0,
- "eol-last": 1,
- "key-spacing": 0,
- "max-depth": [1, 2],
- "max-nested-callbacks": [2, 3],
- "max-params": [1, 4],
- "new-cap": 0,
- "no-multi-spaces": 0,
- "no-shadow": 0,
- "no-trailing-spaces": 1,
- "no-underscore-dangle": 0,
- "quotes": [1, "single"],
- "space-before-function-paren": [1, "always"]
- }
-}
diff --git a/build.js b/build.js
index a6f9f26403e25..fbf2ce932a893 100755
--- a/build.js
+++ b/build.js
@@ -1,113 +1,113 @@
#!/usr/bin/env node
-'use strict';
-
-const Metalsmith = require('metalsmith');
-const autoprefixer = require('autoprefixer-stylus');
-const collections = require('metalsmith-collections');
-const feed = require('metalsmith-feed');
-const layouts = require('metalsmith-layouts');
-const markdown = require('metalsmith-markdown');
-const prism = require('metalsmith-prism');
-const stylus = require('metalsmith-stylus');
-const permalinks = require('metalsmith-permalinks');
-const path = require('path');
-const fs = require('fs');
-const ncp = require('ncp');
-
-const filterStylusPartials = require('./scripts/plugins/filter-stylus-partials');
-const mapHandlebarsPartials = require('./scripts/plugins/map-handlebars-partials');
+'use strict'
+
+const Metalsmith = require('metalsmith')
+const autoprefixer = require('autoprefixer-stylus')
+const collections = require('metalsmith-collections')
+const feed = require('metalsmith-feed')
+const layouts = require('metalsmith-layouts')
+const markdown = require('metalsmith-markdown')
+const prism = require('metalsmith-prism')
+const stylus = require('metalsmith-stylus')
+const permalinks = require('metalsmith-permalinks')
+const path = require('path')
+const fs = require('fs')
+const ncp = require('ncp')
+
+const filterStylusPartials = require('./scripts/plugins/filter-stylus-partials')
+const mapHandlebarsPartials = require('./scripts/plugins/map-handlebars-partials')
const loadVersions = require('./scripts/load-versions')
/** Build **/
// load template.json for given language, but use default language as fallback
// for properties which are not present in the given language
-const DEFAULT_LANG = 'en';
+const DEFAULT_LANG = 'en'
function i18nJSON (lang) {
- var defaultJSON = require(`./locale/${DEFAULT_LANG}/site.json`);
- var templateJSON = require(`./locale/${lang}/site.json`);
- var finalJSON = JSON.parse(JSON.stringify(defaultJSON));
- var merge = function (targetJSON, customJSON) {
- Object.keys(customJSON).forEach(function (key) {
- let value = customJSON[key];
- if (typeof value === 'object') {
- merge(targetJSON[key], value);
- } else {
- targetJSON[key] = value;
- }
- });
- };
- merge(finalJSON, templateJSON);
- return finalJSON;
+ var defaultJSON = require(`./locale/${DEFAULT_LANG}/site.json`)
+ var templateJSON = require(`./locale/${lang}/site.json`)
+ var finalJSON = JSON.parse(JSON.stringify(defaultJSON))
+ var merge = function (targetJSON, customJSON) {
+ Object.keys(customJSON).forEach(function (key) {
+ let value = customJSON[key]
+ if (typeof value === 'object') {
+ merge(targetJSON[key], value)
+ } else {
+ targetJSON[key] = value
+ }
+ })
+ }
+ merge(finalJSON, templateJSON)
+ return finalJSON
}
function buildlocale (source, locale) {
- console.time('[metalsmith] build/' + locale + ' finished');
- const siteJSON = path.join(__dirname, 'locale', locale, 'site.json');
- const metalsmith = Metalsmith(__dirname);
- metalsmith
+ console.time('[metalsmith] build/' + locale + ' finished')
+ const siteJSON = path.join(__dirname, 'locale', locale, 'site.json')
+ const metalsmith = Metalsmith(__dirname)
+ metalsmith
.metadata({
- site: require(siteJSON),
- project: source.project,
- i18n: i18nJSON(locale)
+ site: require(siteJSON),
+ project: source.project,
+ i18n: i18nJSON(locale)
})
.source(path.join(__dirname, 'locale', locale))
.use(collections({
- blog : {
- pattern: 'blog/**/*.md',
- sortBy: 'date',
- reverse: true,
- refer: false
- },
- blogAnnounce : {
- pattern: 'blog/announcements/*.md',
- sortBy: 'date',
- reverse: true,
- refer: false
- },
- blogReleases : {
- pattern: 'blog/release/*.md',
- sortBy: 'date',
- reverse: true,
- refer: false
- },
- blogVulnerability : {
- pattern: 'blog/vulnerability/*.md',
- sortBy: 'date',
- reverse: true,
- refer: false
- },
- lastWeekly: {
- pattern: 'blog/weekly-updates/*.md',
- sortBy: 'date',
- reverse: true,
- refer: false,
- limit: 1
- },
- tscMinutes: {
- pattern: 'foundation/tsc/minutes/*.md',
- sortBy: 'date',
- reverse: true,
- refer: false
- }
+ blog: {
+ pattern: 'blog/**/*.md',
+ sortBy: 'date',
+ reverse: true,
+ refer: false
+ },
+ blogAnnounce: {
+ pattern: 'blog/announcements/*.md',
+ sortBy: 'date',
+ reverse: true,
+ refer: false
+ },
+ blogReleases: {
+ pattern: 'blog/release/*.md',
+ sortBy: 'date',
+ reverse: true,
+ refer: false
+ },
+ blogVulnerability: {
+ pattern: 'blog/vulnerability/*.md',
+ sortBy: 'date',
+ reverse: true,
+ refer: false
+ },
+ lastWeekly: {
+ pattern: 'blog/weekly-updates/*.md',
+ sortBy: 'date',
+ reverse: true,
+ refer: false,
+ limit: 1
+ },
+ tscMinutes: {
+ pattern: 'foundation/tsc/minutes/*.md',
+ sortBy: 'date',
+ reverse: true,
+ refer: false
+ }
}))
.use(markdown({ langPrefix: 'language-' }))
.use(prism())
.use(filterStylusPartials())
.use(stylus({
- compress: true,
- paths:[path.join(__dirname, 'layouts', 'css')],
- use: [autoprefixer()]
+ compress: true,
+ paths: [path.join(__dirname, 'layouts', 'css')],
+ use: [autoprefixer()]
}))
.use(permalinks({
- relative: false
+ relative: false
}))
.use(feed({
- collection: 'blog',
- destination: 'feed/blog.xml',
- title: 'Node.js Blog'
+ collection: 'blog',
+ destination: 'feed/blog.xml',
+ title: 'Node.js Blog'
}))
.use(feed({
collection: 'blogAnnounce',
@@ -115,132 +115,129 @@ function buildlocale (source, locale) {
title: 'Node.js Announcements'
}))
.use(feed({
- collection: 'blogReleases',
- destination: 'feed/releases.xml',
- title: 'Node.js Blog: Releases'
+ collection: 'blogReleases',
+ destination: 'feed/releases.xml',
+ title: 'Node.js Blog: Releases'
}))
.use(feed({
- collection: 'blogVulnerability',
- destination: 'feed/vulnerability.xml',
- title: 'Node.js Blog: Vulnerability Reports'
+ collection: 'blogVulnerability',
+ destination: 'feed/vulnerability.xml',
+ title: 'Node.js Blog: Vulnerability Reports'
}))
.use(feed({
- collection: 'tscMinutes',
- destination: 'feed/tsc-minutes.xml',
- title: 'Node.js Technical Steering Committee meetings'
+ collection: 'tscMinutes',
+ destination: 'feed/tsc-minutes.xml',
+ title: 'Node.js Technical Steering Committee meetings'
}))
.use(layouts({
- engine: 'handlebars',
- pattern: '**/*.html',
- partials: mapHandlebarsPartials(metalsmith, 'layouts', 'partials'),
- helpers: {
- equals: require('./scripts/helpers/equals.js'),
- startswith: require('./scripts/helpers/startswith.js'),
- i18n: require('./scripts/helpers/i18n.js'),
- changeloglink: require('./scripts/helpers/changeloglink.js'),
- strftime: require('./scripts/helpers/strftime.js'),
- apidocslink: require('./scripts/helpers/apidocslink.js')
- }
+ engine: 'handlebars',
+ pattern: '**/*.html',
+ partials: mapHandlebarsPartials(metalsmith, 'layouts', 'partials'),
+ helpers: {
+ equals: require('./scripts/helpers/equals.js'),
+ startswith: require('./scripts/helpers/startswith.js'),
+ i18n: require('./scripts/helpers/i18n.js'),
+ changeloglink: require('./scripts/helpers/changeloglink.js'),
+ strftime: require('./scripts/helpers/strftime.js'),
+ apidocslink: require('./scripts/helpers/apidocslink.js')
+ }
}))
- .destination(path.join(__dirname, 'build', locale));
+ .destination(path.join(__dirname, 'build', locale))
- metalsmith.build(function (err) {
- if (err) { throw err; }
- console.timeEnd('[metalsmith] build/' + locale + ' finished');
- });
+ metalsmith.build(function (err) {
+ if (err) { throw err }
+ console.timeEnd('[metalsmith] build/' + locale + ' finished')
+ })
}
-
function copystatic () {
- console.time('[metalsmith] build/static finished');
- fs.mkdir(path.join(__dirname, 'build'), function () {
- fs.mkdir(path.join(__dirname, 'build', 'static'), function () {
- ncp(path.join(__dirname, 'static'), path.join(__dirname, 'build', 'static'), function (err) {
- if (err) { return console.error(err); }
- console.timeEnd('[metalsmith] build/static finished');
- });
- });
- });
+ console.time('[metalsmith] build/static finished')
+ fs.mkdir(path.join(__dirname, 'build'), function () {
+ fs.mkdir(path.join(__dirname, 'build', 'static'), function () {
+ ncp(path.join(__dirname, 'static'), path.join(__dirname, 'build', 'static'), function (err) {
+ if (err) { return console.error(err) }
+ console.timeEnd('[metalsmith] build/static finished')
+ })
+ })
+ })
}
-
function fullbuild () {
- copystatic();
- loadVersions(function (err, versions) {
- if (err) { throw err; }
- const source = {
- project: {
- versions,
- currentVersion: versions[0].version,
- banner: {
- visible: false,
- content: 'Important security release, please update now!'
- }
- }
- };
-
- fs.readdir(path.join(__dirname, 'locale'), function (e, locales) {
- locales.forEach(function (locale) {
- buildlocale(source, locale);
- });
- });
- });
-}
+ copystatic()
+ loadVersions(function (err, versions) {
+ if (err) { throw err }
+ const source = {
+ project: {
+ versions,
+ currentVersion: versions[0].version,
+ banner: {
+ visible: false,
+ content: 'Important security release, please update now!'
+ }
+ }
+ }
+ fs.readdir(path.join(__dirname, 'locale'), function (e, locales) {
+ locales.forEach(function (locale) {
+ buildlocale(source, locale)
+ })
+ })
+ })
+}
function server () {
- /** Static file server **/
- const st = require('st');
- const http = require('http');
- const mount = st({
- path: path.join(__dirname, 'build'),
- cache: false,
- index: 'index.html'
- });
- http.createServer(
- function (req, res) { mount(req, res); }
- ).listen(8080,
- function () { console.log('http://localhost:8080/en/'); }
- );
-
- /** File Watches for Re-Builds **/
- const chokidar = require('chokidar');
- const opts = {
- persistent: true,
- ignoreInitial: true,
- followSymlinks: true,
- usePolling: true,
- alwaysStat: false,
- depth: undefined,
- interval: 100,
- ignorePermissionErrors: false,
- atomic: true
- };
- const locales = chokidar.watch(path.join(__dirname, 'locale'), opts);
- const layouts = chokidar.watch(path.join(__dirname, 'layouts'), opts);
- const staticf = chokidar.watch(path.join(__dirname, 'static'), opts);
-
- function getlocale (p) {
- const pre = path.join(__dirname, 'locale');
- return p.slice(pre.length + 1, p.indexOf('/', pre.length + 1));
- }
- locales.on('change', function (p) {
- buildlocale(getlocale(p));
- });
- locales.on('add', function (p) {
- buildlocale(getlocale(p));
- locales.add(p);
- });
-
- layouts.on('change', fullbuild);
- layouts.on('add', function (p) { layouts.add(p); fullbuild(); });
-
- staticf.on('change', copystatic);
- staticf.on('add', function (p) { staticf.add(p); copystatic(); });
+ /** Static file server **/
+ const st = require('st')
+ const http = require('http')
+ const mount = st({
+ path: path.join(__dirname, 'build'),
+ cache: false,
+ index: 'index.html'
+ })
+ http.createServer(
+ function (req, res) { mount(req, res) }
+ ).listen(8080,
+ function () { console.log('http://localhost:8080/en/') }
+ )
+
+ /** File Watches for Re-Builds **/
+ const chokidar = require('chokidar')
+ const opts = {
+ persistent: true,
+ ignoreInitial: true,
+ followSymlinks: true,
+ usePolling: true,
+ alwaysStat: false,
+ depth: undefined,
+ interval: 100,
+ ignorePermissionErrors: false,
+ atomic: true
+ }
+ const locales = chokidar.watch(path.join(__dirname, 'locale'), opts)
+ const layouts = chokidar.watch(path.join(__dirname, 'layouts'), opts)
+ const staticf = chokidar.watch(path.join(__dirname, 'static'), opts)
+
+ function getlocale (p) {
+ const pre = path.join(__dirname, 'locale')
+ return p.slice(pre.length + 1, p.indexOf('/', pre.length + 1))
+ }
+ locales.on('change', function (p) {
+ buildlocale(getlocale(p))
+ })
+ locales.on('add', function (p) {
+ buildlocale(getlocale(p))
+ locales.add(p)
+ })
+
+ layouts.on('change', fullbuild)
+ layouts.on('add', function (p) { layouts.add(p); fullbuild() })
+
+ staticf.on('change', copystatic)
+ staticf.on('add', function (p) { staticf.add(p); copystatic() })
}
-fullbuild();
+fullbuild()
if (process.argv[2] === 'serve') {
- server();
+ server()
}
diff --git a/package.json b/package.json
index 116ca2bedaa43..34eaca811d3f8 100644
--- a/package.json
+++ b/package.json
@@ -6,9 +6,9 @@
"scripts": {
"build": "node build.js",
"serve": "node build.js serve",
- "lint": "eslint scripts build.js",
"load-versions": "node scripts/load-versions.js",
- "start": "npm run serve"
+ "start": "npm run serve",
+ "test": "standard build.js scripts/**/*.js --format"
},
"repository": {
"type": "git",
@@ -46,7 +46,7 @@
"strftime": "^0.9.2"
},
"devDependencies": {
- "babel-eslint": "^4.0.10",
- "eslint": "^1.1.0"
+ "pre-commit": "^1.1.1",
+ "standard": "^5.3.0"
}
}
diff --git a/scripts/helpers/apidocslink.js b/scripts/helpers/apidocslink.js
index 85d8aedfbad8b..87611631153e9 100644
--- a/scripts/helpers/apidocslink.js
+++ b/scripts/helpers/apidocslink.js
@@ -1,13 +1,11 @@
'use strict'
-const semver = require('semver');
-
+const semver = require('semver')
module.exports = function (version) {
+ if (!version) { return '' }
- if (!version) { return ''; }
-
- return semver.satisfies(version, '>=1.0.0 <4.0.0') ?
- `https://iojs.org/dist/${version}/docs/api/` :
- `https://nodejs.org/dist/${version}/docs/api/`;
-};
+ return semver.satisfies(version, '>=1.0.0 <4.0.0')
+ ? `https://iojs.org/dist/${version}/docs/api/`
+ : `https://nodejs.org/dist/${version}/docs/api/`
+}
diff --git a/scripts/helpers/changeloglink.js b/scripts/helpers/changeloglink.js
index 8fa7397103c65..939783bad9f19 100644
--- a/scripts/helpers/changeloglink.js
+++ b/scripts/helpers/changeloglink.js
@@ -1,13 +1,15 @@
'use strict'
-const semver = require('semver');
-
+const semver = require('semver')
module.exports = function (version) {
+ if (!version) { return '' }
- if (!version) { return ''; }
+ const legacyLink = semver.satisfies(version, '>=1.0.0 <4.0.0')
+ ? `https://github.com/nodejs/io.js/blob/${version}/CHANGELOG.md`
+ : `https://github.com/nodejs/node-v0.x-archive/blob/${version}/ChangeLog`
- return semver.gte(version, '1.0.0') ?
- `https://github.com/nodejs/io.js/blob/${version}/CHANGELOG.md` :
- `https://github.com/joyent/node/blob/${version}/ChangeLog`;
-};
+ return semver.gte(version, '4.0.0')
+ ? `https://github.com/nodejs/node/blob/${version}/CHANGELOG.md`
+ : legacyLink
+}
diff --git a/scripts/helpers/equals.js b/scripts/helpers/equals.js
index 0814e74f49570..8114875a9e59e 100644
--- a/scripts/helpers/equals.js
+++ b/scripts/helpers/equals.js
@@ -1,5 +1,5 @@
'use strict'
module.exports = function (v1, v2, options) {
- return (v1 === v2) ? options.fn(this) : options.inverse(this);
-};
+ return (v1 === v2) ? options.fn(this) : options.inverse(this)
+}
diff --git a/scripts/helpers/i18n.js b/scripts/helpers/i18n.js
index 6112f87ba2318..a677ac167015f 100644
--- a/scripts/helpers/i18n.js
+++ b/scripts/helpers/i18n.js
@@ -1,28 +1,29 @@
'use strict'
-const Handlebars = require('handlebars');
-
+const Handlebars = require('handlebars')
function traverse (obj, str) {
- return str.split('.').reduce(function (o, x) { return o[x]; }, obj);
+ return str.split('.').reduce(function (o, x) {
+ return o[x]
+ }, obj)
}
module.exports = function () {
- var env, key;
+ var env, key
- // function(key, env)
- if (arguments.length === 2) {
- key = arguments[0];
- env = arguments[1];
- }
- // function(scope, key, env)
- if (arguments.length === 3) {
- key = arguments[0] + '.' + arguments[1];
- env = arguments[2];
- }
+ // function(key, env)
+ if (arguments.length === 2) {
+ key = arguments[0]
+ env = arguments[1]
+ }
+ // function(scope, key, env)
+ if (arguments.length === 3) {
+ key = arguments[0] + '.' + arguments[1]
+ env = arguments[2]
+ }
- var data = env.data.root;
- var result = traverse(data.i18n, key);
+ var data = env.data.root
+ var result = traverse(data.i18n, key)
- return new Handlebars.SafeString(result);
-};
+ return new Handlebars.SafeString(result)
+}
diff --git a/scripts/helpers/startswith.js b/scripts/helpers/startswith.js
index 845b28af6ce59..823d4d582199c 100644
--- a/scripts/helpers/startswith.js
+++ b/scripts/helpers/startswith.js
@@ -1,5 +1,5 @@
'use strict'
module.exports = function (v1, v2, options) {
- return (v1 && v1.indexOf(v2) === 0) ? options.fn(this) : options.inverse(this);
-};
+ return (v1 && v1.indexOf(v2) === 0) ? options.fn(this) : options.inverse(this)
+}
diff --git a/scripts/helpers/strftime.js b/scripts/helpers/strftime.js
index 7005ef8245608..b21354e24ccfb 100644
--- a/scripts/helpers/strftime.js
+++ b/scripts/helpers/strftime.js
@@ -1,19 +1,17 @@
'use strict'
-const strftime = require('strftime');
-
+const strftime = require('strftime')
module.exports = function (date, format) {
+ let parsedDate = new Date(date)
- let parsedDate = new Date(date);
-
- if (!(parsedDate instanceof Date && isFinite(parsedDate))) {
- // If date is invalid (but not undefined) log error for debugging
- if (date && process.env.NODE_ENV !== 'test') {
- console.error('[handlebars] strftime - Invalid date:', date);
- }
- return date;
+ if (!(parsedDate instanceof Date && isFinite(parsedDate))) {
+ // If date is invalid (but not undefined) log error for debugging
+ if (date && process.env.NODE_ENV !== 'test') {
+ console.error('[handlebars] strftime - Invalid date:', date)
}
+ return date
+ }
- return strftime(typeof format === 'string' && format ? format : '%F', parsedDate);
-};
+ return strftime(typeof format === 'string' && format ? format : '%F', parsedDate)
+}
diff --git a/scripts/load-versions.js b/scripts/load-versions.js
index 4bc801d2eccb5..1b33acd596608 100755
--- a/scripts/load-versions.js
+++ b/scripts/load-versions.js
@@ -1,71 +1,70 @@
#!/usr/bin/env node
-'use strict';
+'use strict'
-const fs = require('fs');
-const semver = require('semver');
-const map = require('map-async');
-const https = require('https');
+const fs = require('fs')
+const semver = require('semver')
+const map = require('map-async')
+const https = require('https')
function loadVersions (callback) {
- map(
- [ 'https://nodejs.org/dist/index.json', 'https://iojs.org/dist/index.json' ],
- download,
- function (err, versions) {
- if (err)
- return callback(err);
- versions = munge(versions);
- callback(null, versions);
- }
- );
+ map(
+ [ 'https://nodejs.org/dist/index.json', 'https://iojs.org/dist/index.json' ],
+ download,
+ function (err, versions) {
+ if (err) { return callback(err) }
+ versions = munge(versions)
+ callback(null, versions)
+ }
+ )
}
function download (url, cb) {
- let data = '';
- https.get(url, function (res) {
- res.on('data', function (chunk) { data += chunk; });
- res.on('end', function () {
- try {
- cb(null, JSON.parse(data));
- } catch (e) {
- return cb(e);
- }
- });
- }).on('error', function (e) {
- console.error('Error downloading file from %s: %s', url, e.message);
- cb(e);
- });
+ let data = ''
+ https.get(url, function (res) {
+ res.on('data', function (chunk) { data += chunk })
+ res.on('end', function () {
+ try {
+ cb(null, JSON.parse(data))
+ } catch (e) {
+ return cb(e)
+ }
+ })
+ }).on('error', function (e) {
+ console.error('Error downloading file from %s: %s', url, e.message)
+ cb(e)
+ })
}
function munge (versions) {
- versions[0].forEach(function (v) {
- v.url = 'https://nodejs.org/dist/' + v.version + '/'
- v.name = 'Node.js'
- });
- versions[1].forEach(function (v) {
- v.url = 'https://iojs.org/dist/' + v.version + '/'
- v.name = 'io.js'
- });
+ versions[0].forEach(function (v) {
+ v.url = 'https://nodejs.org/dist/' + v.version + '/'
+ v.name = 'Node.js'
+ })
+ versions[1].forEach(function (v) {
+ v.url = 'https://iojs.org/dist/' + v.version + '/'
+ v.name = 'io.js'
+ })
- let allVersions = versions[0].concat(versions[1]);
+ let allVersions = versions[0].concat(versions[1])
- allVersions.sort(function (a, b) {
- return semver.compare(b.version, a.version);
- });
+ allVersions.sort(function (a, b) {
+ return semver.compare(b.version, a.version)
+ })
- return allVersions;
+ return allVersions
}
-module.exports = loadVersions;
+module.exports = loadVersions
if (require.main === module) {
- loadVersions(function (err, versions) {
- if (err) {
- console.error('Aborting due to download error from node or iojs');
- console.error(err.stack);
- return process.exit(1);
- }
+ loadVersions(function (err, versions) {
+ if (err) {
+ console.error('Aborting due to download error from node or iojs')
+ console.error(err.stack)
+ return process.exit(1)
+ }
- fs.writeFileSync(__dirname + '/../source/versions.json', JSON.stringify(versions, null, 2));
- })
-}
\ No newline at end of file
+ fs.writeFileSync(__dirname + '/../source/versions.json', JSON.stringify(versions, null, 2))
+ })
+}
diff --git a/scripts/plugins/debug.js b/scripts/plugins/debug.js
index 3696a95530ab8..7df2a55ad13cd 100644
--- a/scripts/plugins/debug.js
+++ b/scripts/plugins/debug.js
@@ -1,16 +1,13 @@
-'use strict';
-
-const Util = require('util');
+'use strict'
+const Util = require('util')
module.exports = function debug () {
-
- return function (files, metalsmith, done) {
-
- console.log('\n\n');
- console.log(Util.inspect(metalsmith.metadata(), { showHidden: false, depth: null }));
- console.log(Util.inspect(files, { showHidden: false, depth: null }));
- console.log('\n\n');
- done();
- };
-};
+ return function (files, metalsmith, done) {
+ console.log('\n\n')
+ console.log(Util.inspect(metalsmith.metadata(), { showHidden: false, depth: null }))
+ console.log(Util.inspect(files, { showHidden: false, depth: null }))
+ console.log('\n\n')
+ done()
+ }
+}
diff --git a/scripts/plugins/filter-stylus-partials.js b/scripts/plugins/filter-stylus-partials.js
index 0495bea0d75b6..2bec46335fdb4 100644
--- a/scripts/plugins/filter-stylus-partials.js
+++ b/scripts/plugins/filter-stylus-partials.js
@@ -1,18 +1,16 @@
-'use strict';
-
-const Path = require('path');
+'use strict'
+const Path = require('path')
module.exports = function filterStylusPartials () {
+ return function (files, metalsmith, done) {
+ Object.keys(files).forEach(function (filename) {
+ const isPartial = (/^_.*\.styl(us)?/).test(Path.basename(filename))
+ if (isPartial) {
+ delete files[filename]
+ }
+ })
- return function (files, metalsmith, done) {
-
- Object.keys(files).forEach(function (filename) {
-
- const isPartial = (/^_.*\.styl(us)?/).test(Path.basename(filename));
- if (isPartial) { delete files[filename]; }
- });
-
- done();
- };
-};
+ done()
+ }
+}
diff --git a/scripts/plugins/map-handlebars-partials.js b/scripts/plugins/map-handlebars-partials.js
index 26e303e067d99..05bba4d4ff5f6 100644
--- a/scripts/plugins/map-handlebars-partials.js
+++ b/scripts/plugins/map-handlebars-partials.js
@@ -1,23 +1,20 @@
-'use strict';
-
-const Fs = require('fs');
-const Path = require('path');
+'use strict'
+const Fs = require('fs')
+const Path = require('path')
/**
* Map handlebars partials as { $partialName: $partialPath/$partialName }
*/
module.exports = function mapHandlebarsPartials (metalsmith, layoutPath, partialPath) {
+ const fullPath = metalsmith.path(layoutPath, partialPath)
+ let partials = {}
- const fullPath = metalsmith.path(layoutPath, partialPath);
- let partials = {};
-
- Fs.readdirSync(fullPath).forEach(function (file) {
-
- if ( Path.extname(file) !== '.hbs') { return; }
- const partialName = Path.basename(file, '.hbs');
- partials[partialName] = Path.join(partialPath, partialName);
- });
+ Fs.readdirSync(fullPath).forEach(function (file) {
+ if (Path.extname(file) !== '.hbs') { return }
+ const partialName = Path.basename(file, '.hbs')
+ partials[partialName] = Path.join(partialPath, partialName)
+ })
- return partials;
-};
+ return partials
+}
diff --git a/scripts/release-post.js b/scripts/release-post.js
index 8d9f3e2336d98..7b74e6d7b892c 100755
--- a/scripts/release-post.js
+++ b/scripts/release-post.js
@@ -1,7 +1,5 @@
#!/usr/bin/env node
-'use strict';
-
/**
* What's this?? It will help you create release blog
* posts so you wont have to do the tedious work
@@ -20,116 +18,120 @@
* Happy releasing!
*/
-const https = require('https');
-const fs = require('fs');
-const path = require('path');
-const extend = require('util')._extend;
-const Handlebars = require('handlebars');
+'use strict'
+
+const https = require('https')
+const fs = require('fs')
+const path = require('path')
+const extend = require('util')._extend
+const Handlebars = require('handlebars')
function download (url, cb) {
- return new Promise(function (resolve, reject) {
- let data = '';
- https.get(url, function (res) {
- if (res.statusCode !== 200) {
- return reject(new Error('Invalid status code (!= 200) while retrieving '+ url +': '+ res.statusCode));
- }
-
- res.on('data', function (chunk) { data += chunk; });
- res.on('end', function () { resolve(data); });
- }).on('error', function (err) {
- reject(new Error('Error downloading file from %s: %s', url, err.message));
- });
- });
+ return new Promise(function (resolve, reject) {
+ let data = ''
+ https.get(url, function (res) {
+ if (res.statusCode !== 200) {
+ return reject(new Error('Invalid status code (!= 200) while retrieving ' + url + ': ' + res.statusCode))
+ }
+
+ res.on('data', function (chunk) { data += chunk })
+ res.on('end', function () { resolve(data) })
+ }).on('error', function (err) {
+ reject(new Error('Error downloading file from %s: %s', url, err.message))
+ })
+ })
}
// matches a complete release section, support both old node and iojs releases:
// ## 2015-07-09, Version 0.12.7 (Stable)
// ## 2015-08-04, Version 3.0.0, @rvagg
-const rxReleaseSection = /## \d{4}-\d{2}-\d{2}, Version ([^,( ]+)[\s\S]*?(?=## \d{4})/g;
+const rxReleaseSection = /## \d{4}-\d{2}-\d{2}, Version ([^,( ]+)[\s\S]*?(?=## \d{4})/g
-function explicitVersion() {
- const versionArg = process.argv[2];
- return versionArg ? Promise.resolve(versionArg) : Promise.reject();
+function explicitVersion () {
+ const versionArg = process.argv[2]
+ return versionArg ? Promise.resolve(versionArg) : Promise.reject()
}
function findLatestVersion (cb) {
- return download('https://nodejs.org/dist/index.json')
- .then(JSON.parse)
- .then(function (versions) {
- return versions[0].version.substr(1);
- });
+ return download('https://nodejs.org/dist/index.json')
+ .then(JSON.parse)
+ .then(function (versions) {
+ return versions[0].version.substr(1)
+ })
}
function fetchDocs (version) {
- return Promise.all([ fetchChangelog(version), fetchShasums(version) ]).then(function (results) {
- const changelog = results[0];
- const shasums = results[1];
-
- return {
- version,
- changelog,
- shasums
- };
- });
+ return Promise.all([ fetchChangelog(version), fetchShasums(version) ]).then(function (results) {
+ const changelog = results[0]
+ const shasums = results[1]
+
+ return {
+ version,
+ changelog,
+ shasums
+ }
+ })
}
function fetchChangelog (version) {
- return download(`https://raw.githubusercontent.com/nodejs/node/v${version}/CHANGELOG.md`)
- .then(function (data) {
- let matches;
-
- while (matches = rxReleaseSection.exec(data)) {
- const releaseVersion = matches[1];
- if (releaseVersion === version) {
- return matches[0];
- }
- }
-
- return Promise.reject(new Error('Couldnt find matching changelog for ' + version));
- });
+ return download(`https://raw.githubusercontent.com/nodejs/node/v${version}/CHANGELOG.md`)
+ .then(function (data) {
+ let matches
+
+ /* eslint-disable no-cond-assign */
+ while (matches = rxReleaseSection.exec(data)) {
+ const releaseVersion = matches[1]
+ if (releaseVersion === version) {
+ return matches[0]
+ }
+ }
+ /* eslint-enable no-cond-assign */
+
+ return Promise.reject(new Error('Couldnt find matching changelog for ' + version))
+ })
}
function fetchShasums (version) {
- return download(`https://nodejs.org/dist/v${version}/SHASUMS256.txt.asc`)
- .then(null, () => '[INSERT SHASUMS HERE]');
+ return download(`https://nodejs.org/dist/v${version}/SHASUMS256.txt.asc`)
+ .then(null, () => '[INSERT SHASUMS HERE]')
}
function renderPost (results) {
- const templateStr = fs.readFileSync(path.resolve(__dirname, 'release.hbs')).toString('utf8');
- const template = Handlebars.compile(templateStr, { noEscape: true });
- const view = extend({
- date: new Date().toISOString(),
- versionSlug: slugify(results.version)
- }, results);
-
- return extend({
- content: template(view)
- }, results);
+ const templateStr = fs.readFileSync(path.resolve(__dirname, 'release.hbs')).toString('utf8')
+ const template = Handlebars.compile(templateStr, { noEscape: true })
+ const view = extend({
+ date: new Date().toISOString(),
+ versionSlug: slugify(results.version)
+ }, results)
+
+ return extend({
+ content: template(view)
+ }, results)
}
function writeToFile (results) {
- const filepath = path.resolve(__dirname, '..', 'locale', 'en', 'blog', 'release', `v${results.version}.md`);
+ const filepath = path.resolve(__dirname, '..', 'locale', 'en', 'blog', 'release', `v${results.version}.md`)
- if (fs.existsSync(filepath)) {
- return Promise.reject(new Error(`Release post for ${results.version} already exists!`));
- }
+ if (fs.existsSync(filepath)) {
+ return Promise.reject(new Error(`Release post for ${results.version} already exists!`))
+ }
- fs.writeFileSync(filepath, results.content);
- return Promise.resolve(filepath);
+ fs.writeFileSync(filepath, results.content)
+ return Promise.resolve(filepath)
}
function slugify (str) {
- return str.replace(/\./g, '-');
+ return str.replace(/\./g, '-')
}
explicitVersion()
- .then(null, findLatestVersion)
- .then(fetchDocs)
- .then(renderPost)
- .then(writeToFile)
- .then(function (filepath) {
- console.log('Release post created:', filepath);
- }, function (err) {
- console.error('Some error occured here!', err.stack);
- process.exit(1);
- });
+ .then(null, findLatestVersion)
+ .then(fetchDocs)
+ .then(renderPost)
+ .then(writeToFile)
+ .then(function (filepath) {
+ console.log('Release post created:', filepath)
+ }, function (err) {
+ console.error('Some error occured here!', err.stack)
+ process.exit(1)
+ })
diff --git a/scripts/tasks/download.js b/scripts/tasks/download.js
index d651b44b5c981..401678782446d 100644
--- a/scripts/tasks/download.js
+++ b/scripts/tasks/download.js
@@ -1,13 +1,12 @@
-'use strict';
+'use strict'
-var github = require('octonode');
-var client = github.client();
-var evRepo = client.repo('nodejs/evangelism');
+var github = require('octonode')
+var client = github.client()
+var evRepo = client.repo('nodejs/evangelism')
-var https = require('https');
-var path = require('path');
-var fs = require('fs');
-var crypto = require('crypto');
+var https = require('https')
+var path = require('path')
+var fs = require('fs')
/* Currently proof-of-concept work. Outstanding:
* ================
@@ -19,24 +18,24 @@ var crypto = require('crypto');
*/
function checkOrFetchFile (file) {
- let name = file.name;
- let downloadUrl = file.download_url;
- let sha = file.sha;
+ let name = file.name
+ let downloadUrl = file.download_url
- let localPath = path.join(__dirname, '..', '..', 'locale', 'en', 'blog', 'weekly-updates', name);
+ let localPath = path.join(__dirname, '..', '..', 'locale', 'en', 'blog', 'weekly-updates', name)
if (fs.existsSync(localPath)) {
console.log(`Weekly Update ${name} exists. (No SHA check, yet.)`)
- return;
+ return
}
- console.log(`Weekly Update ${name} does not exist. Downloading.`);
+ console.log(`Weekly Update ${name} does not exist. Downloading.`)
- var file = fs.createWriteStream(localPath);
- var request = https.get(downloadUrl, function (response) {
- response.pipe(file);
- });
+ var outputFile = fs.createWriteStream(localPath)
+ https.get(downloadUrl, function (response) {
+ response.pipe(outputFile)
+ })
}
evRepo.contents('weekly-updates', function (err, files) {
- files.forEach(checkOrFetchFile);
+ if (err) { throw err }
+ files.forEach(checkOrFetchFile)
})