Skip to content

Commit

Permalink
Merge 0ec0f90 into 660ad12
Browse files Browse the repository at this point in the history
  • Loading branch information
tripu committed Jul 23, 2018
2 parents 660ad12 + 0ec0f90 commit 9f9a3d9
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 107 deletions.
15 changes: 15 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"env": {
"node": true,
"browser": true,
"mocha": true
},
"plugins": ["node"],
"extends": [
"eslint:recommended",
"plugin:node/recommended"
],
"rules": {
"node/no-unpublished-require": "off"
}
}
71 changes: 0 additions & 71 deletions .jscs.json

This file was deleted.

5 changes: 0 additions & 5 deletions .nsprc

This file was deleted.

5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ language: node_js
node_js:
- "8"
- "10"
before_install:
- npm i -g npm@latest
before_script:
- cp config.js.example config.js
script:
- API_KEY=${API_KEY:-foo} npm test
- npm run nsp
- API_KEY=${API_KEY:-foo} npm run build
after_script:
- npm run coveralls
notifications:
Expand Down
15 changes: 9 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* @module
*/

/* eslint-disable no-console */

'use strict';

console.log('Launching…');
Expand Down Expand Up @@ -67,12 +69,13 @@ app.get('/api/status', function (req, res) {
var file = argResultLocation + path.sep + id + '.json';

if (id) {
Fs.exists(file, function (exists) {
if (exists) res.status(200).sendFile(file);
else if (requests && requests[id]) {
res.status(200).json(requests[id]);
}
else res.status(404).send('No job found with ID “' + id + '”.');
Fs.access(file, Fs.constants.F_OK, function (error) {
if (!error)
res.status(200).sendFile(file);
else if (requests && requests[id])
res.status(200).json(requests[id]);
else
res.status(404).send('No job found with ID “' + id + '”.');
});
}
else res.status(400).send('Missing required parameter “ID”.');
Expand Down
6 changes: 2 additions & 4 deletions assets/js/behaviour.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* @author Antonio <antonio@w3.org>
*/

/* eslint-env jquery */

'use strict';

$(document).ready(function () {
Expand All @@ -23,10 +25,6 @@ $(document).ready(function () {
$('#lastUpdate > span').text(new Date()
.toLocaleTimeString());
}
else if (400 === xhr.status || 404 === xhr.status) {
// No job found with that ID, or parameter is missing:
console.log(data);
}
else {
// Some other kind of error:
window.alert(data);
Expand Down
9 changes: 9 additions & 0 deletions jsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"opts": {
"access": "all",
"destination": "doc/api/",
"encoding": "utf8",
"recurse": true,
"template": "node_modules/minami"
}
}
2 changes: 2 additions & 0 deletions known-vulns.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
https://nodesecurity.io/advisories/577
https://nodesecurity.io/advisories/577
2 changes: 1 addition & 1 deletion lib/document-downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ DocumentDownloader.fetchAndInstall = function (url, dest) {
var mkdir = Promise.denodeify(Fs.mkdir);

return new Promise(function (resolve) {
Fs.exists(dest, function (exists) { resolve(exists); });
Fs.access(dest, Fs.constants.F_OK, function (error) { resolve(!error); });
}).then(function (pathExists) {
if (!pathExists) return mkdir(dest);
}).then(function () {
Expand Down
2 changes: 1 addition & 1 deletion lib/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function appendToLog(filename, message) {
new Date().toISOString() + '\t' + message + '\n',
'utf8',
function (err) {
if (err) console.error('ERROR: can\'t write to log file.\n' + err);
if (err) throw new Error('ERROR: can\'t write to log file.\n' + err);
}
);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/orchestrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ Orchestrator.prototype.runStep = function (step) {

return state;
})
.catch(function (err) {
console.log(err.stack);
.catch(function () {

state = state.set('status', 'error');
state = state.addToHistory(
Expand Down
26 changes: 14 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,30 @@
"chai": "4.1.2",
"chai-as-promised": "7.1.1",
"chai-immutable": "2.0.0-rc.2",
"coveralls": "3.0.1",
"coveralls": "3.0.2",
"eslint": "5.2.0",
"eslint-plugin-node": "7.0.1",
"istanbul": "0.4.5",
"jscs": "3.0.7",
"jsdoc": "3.5.5",
"jshint": "2.9.5",
"minami": "1.2.3",
"mocha": "5.2.0",
"morgan": "1.9.0",
"nsp": "3.2.1"
"morgan": "1.9.0"
},
"scripts": {
"check-style": "jscs .",
"audit": "npm audit | grep -oP 'https://nodesecurity.io/advisories/(\\d+)' | diff known-vulns.txt -",
"lint": "eslint app.js assets/js/ lib/ test/",
"hint": "jshint app.js assets/js/ lib/ test/",
"testserver": "node test/lib/testserver",
"test": "mocha",
"jsdoc": "jsdoc --configure jsdoc.json -r app.js assets/js/ lib/ test/",
"coverage": "istanbul cover _mocha",
"coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls",
"jsdoc": "jsdoc -a all -d doc/api/ -e utf8 -r app.js lib/ test/",
"lint": "jshint .",
"nsp": "nsp check",
"start": "node app.js",
"test": "npm run check-style && npm run lint && mocha",
"testserver": "node test/lib/testserver"
"build": "npm run audit && npm run lint && npm run hint && npm run test && npm run jsdoc",
"start": "node app"
},
"engines": {
"node": "8 || 10",
"npm": "5"
"npm": ">=6"
}
}
2 changes: 1 addition & 1 deletion test/lib/htmltemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function htmlTemplate(serverPath, fileSystemPath) {
else if (metadata[name] !== undefined) {
replacement += metadata[name];
}
else console.log('htmltemplate.js: %s not a valid substitution', name);
else throw new Error('htmltemplate.js: %s not a valid substitution', name);

return str.substring(oldstart, start) + replacement + replace(end + 2);
}
Expand Down
2 changes: 1 addition & 1 deletion test/test-orchestrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Orchestrator', function () {
return Orchestrator.iterate(
function (i) { return List.of(f(i)); },
function (i) { return i >= n; },
function (i) { },
function () { },
0
);
}
Expand Down
3 changes: 2 additions & 1 deletion test/views/behaviour.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @author Antonio <antonio@w3.org>
*/

/* eslint-env jquery */

'use strict';

var JOBS = [
Expand Down Expand Up @@ -171,7 +173,6 @@ $(document).ready(function () {
$.getJSON('data/specs.json', function (data) {
var tableBody = $('table#specList > tbody');
var row;
var cell;

$.each(data.specs, function (foo, spec) {
allSpecs.push(spec);
Expand Down

0 comments on commit 9f9a3d9

Please sign in to comment.