mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
Add ESLint to gulp scripts (#9259)
* Remove gulp/* and gulpfile from ESLint ignores * Update .eslintrc in local gulp folder * Start work on refactoring gulp files * add radix * Add line-specific eslint exceptions * removed redundant eslint file for gulp * add more exceptions * Add exceptions to main gulpfile.js
This commit is contained in:
committed by
Matteo Pagliazzi
parent
638259b885
commit
9736ef0d25
@@ -16,5 +16,3 @@ migrations/*
|
|||||||
scripts/*
|
scripts/*
|
||||||
website/common/browserify.js
|
website/common/browserify.js
|
||||||
Gruntfile.js
|
Gruntfile.js
|
||||||
gulpfile.js
|
|
||||||
gulp
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"root": true,
|
|
||||||
"env": {
|
|
||||||
"node": true,
|
|
||||||
},
|
|
||||||
"extends": [
|
|
||||||
"habitrpg/server",
|
|
||||||
"habitrpg/babel"
|
|
||||||
],
|
|
||||||
}
|
|
||||||
@@ -22,5 +22,5 @@ gulp.task('apidoc', ['apidoc:clean'], (done) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('apidoc:watch', ['apidoc'], () => {
|
gulp.task('apidoc:watch', ['apidoc'], () => {
|
||||||
return gulp.watch(APIDOC_SRC_PATH + '/**/*.js', ['apidoc']);
|
return gulp.watch(`${APIDOC_SRC_PATH}/**/*.js`, ['apidoc']);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ const BOOSTRAP_NEW_CONFIG_PATH = 'website/client/assets/scss/bootstrap_config.sc
|
|||||||
const BOOTSTRAP_ORIGINAL_CONFIG_PATH = 'node_modules/bootstrap/scss/_custom.scss';
|
const BOOTSTRAP_ORIGINAL_CONFIG_PATH = 'node_modules/bootstrap/scss/_custom.scss';
|
||||||
|
|
||||||
// https://stackoverflow.com/a/14387791/969528
|
// https://stackoverflow.com/a/14387791/969528
|
||||||
function copyFile(source, target, cb) {
|
function copyFile (source, target, cb) {
|
||||||
let cbCalled = false;
|
let cbCalled = false;
|
||||||
|
|
||||||
function done(err) {
|
function done (err) {
|
||||||
if (!cbCalled) {
|
if (!cbCalled) {
|
||||||
cb(err);
|
cb(err);
|
||||||
cbCalled = true;
|
cbCalled = true;
|
||||||
@@ -33,4 +33,4 @@ gulp.task('bootstrap', (done) => {
|
|||||||
BOOTSTRAP_ORIGINAL_CONFIG_PATH,
|
BOOTSTRAP_ORIGINAL_CONFIG_PATH,
|
||||||
done,
|
done,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import gulp from 'gulp';
|
import gulp from 'gulp';
|
||||||
import runSequence from 'run-sequence';
|
|
||||||
import babel from 'gulp-babel';
|
import babel from 'gulp-babel';
|
||||||
import webpackProductionBuild from '../webpack/build';
|
import webpackProductionBuild from '../webpack/build';
|
||||||
|
|
||||||
gulp.task('build', () => {
|
gulp.task('build', () => {
|
||||||
if (process.env.NODE_ENV === 'production') {
|
if (process.env.NODE_ENV === 'production') { // eslint-disable-line no-process-env
|
||||||
gulp.start('build:prod');
|
gulp.start('build:prod');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -27,12 +26,12 @@ gulp.task('build:server', ['build:src', 'build:common']);
|
|||||||
gulp.task('build:client', ['bootstrap'], (done) => {
|
gulp.task('build:client', ['bootstrap'], (done) => {
|
||||||
webpackProductionBuild((err, output) => {
|
webpackProductionBuild((err, output) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
console.log(output);
|
console.log(output); // eslint-disable-line no-console
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('build:prod', [
|
gulp.task('build:prod', [
|
||||||
'build:server',
|
'build:server',
|
||||||
'build:client',
|
'build:client',
|
||||||
'apidoc',
|
'apidoc',
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -7,10 +7,11 @@ import gulp from 'gulp';
|
|||||||
|
|
||||||
// Add additional properties to the repl's context
|
// Add additional properties to the repl's context
|
||||||
let improveRepl = (context) => {
|
let improveRepl = (context) => {
|
||||||
|
|
||||||
// Let "exit" and "quit" terminate the console
|
// Let "exit" and "quit" terminate the console
|
||||||
['exit', 'quit'].forEach((term) => {
|
['exit', 'quit'].forEach((term) => {
|
||||||
Object.defineProperty(context, term, { get () { process.exit(); }});
|
Object.defineProperty(context, term, { get () {
|
||||||
|
process.exit();
|
||||||
|
}});
|
||||||
});
|
});
|
||||||
|
|
||||||
// "clear" clears the screen
|
// "clear" clears the screen
|
||||||
@@ -18,12 +19,12 @@ let improveRepl = (context) => {
|
|||||||
process.stdout.write('\u001B[2J\u001B[0;0f');
|
process.stdout.write('\u001B[2J\u001B[0;0f');
|
||||||
}});
|
}});
|
||||||
|
|
||||||
context.Challenge = require('../website/server/models/challenge').model;
|
context.Challenge = require('../website/server/models/challenge').model; // eslint-disable-line global-require
|
||||||
context.Group = require('../website/server/models/group').model;
|
context.Group = require('../website/server/models/group').model; // eslint-disable-line global-require
|
||||||
context.User = require('../website/server/models/user').model;
|
context.User = require('../website/server/models/user').model; // eslint-disable-line global-require
|
||||||
|
|
||||||
var isProd = nconf.get('NODE_ENV') === 'production';
|
const isProd = nconf.get('NODE_ENV') === 'production';
|
||||||
var mongooseOptions = !isProd ? {} : {
|
const mongooseOptions = !isProd ? {} : {
|
||||||
replset: { socketOptions: { keepAlive: 1, connectTimeoutMS: 30000 } },
|
replset: { socketOptions: { keepAlive: 1, connectTimeoutMS: 30000 } },
|
||||||
server: { socketOptions: { keepAlive: 1, connectTimeoutMS: 30000 } },
|
server: { socketOptions: { keepAlive: 1, connectTimeoutMS: 30000 } },
|
||||||
};
|
};
|
||||||
@@ -31,16 +32,15 @@ let improveRepl = (context) => {
|
|||||||
mongoose.connect(
|
mongoose.connect(
|
||||||
nconf.get('NODE_DB_URI'),
|
nconf.get('NODE_DB_URI'),
|
||||||
mongooseOptions,
|
mongooseOptions,
|
||||||
function (err) {
|
(err) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
logger.info('Connected with Mongoose');
|
logger.info('Connected with Mongoose');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
gulp.task('console', (cb) => {
|
gulp.task('console', () => {
|
||||||
improveRepl(repl.start({
|
improveRepl(repl.start({
|
||||||
prompt: 'Habitica > ',
|
prompt: 'Habitica > ',
|
||||||
}).context);
|
}).context);
|
||||||
|
|||||||
@@ -14,75 +14,35 @@ const MAX_SPRITESHEET_SIZE = 1024 * 1024 * 3;
|
|||||||
const IMG_DIST_PATH = 'website/static/sprites/';
|
const IMG_DIST_PATH = 'website/static/sprites/';
|
||||||
const CSS_DIST_PATH = 'website/client/assets/css/sprites/';
|
const CSS_DIST_PATH = 'website/client/assets/css/sprites/';
|
||||||
|
|
||||||
gulp.task('sprites:compile', ['sprites:clean', 'sprites:main', 'sprites:largeSprites', 'sprites:checkCompiledDimensions']);
|
function checkForSpecialTreatment (name) {
|
||||||
|
let regex = /^hair|skin|beard|mustach|shirt|flower|^headAccessory_special_\w+Ears|^eyewear_special_\w+TopFrame/;
|
||||||
|
return name.match(regex) || name === 'head_0';
|
||||||
|
}
|
||||||
|
|
||||||
gulp.task('sprites:main', () => {
|
function calculateImgDimensions (img, addPadding) {
|
||||||
let mainSrc = sync('website/raw_sprites/spritesmith/**/*.png');
|
let dims = sizeOf(img);
|
||||||
return createSpritesStream('main', mainSrc);
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('sprites:largeSprites', () => {
|
let requiresSpecialTreatment = checkForSpecialTreatment(img);
|
||||||
let largeSrc = sync('website/raw_sprites/spritesmith_large/**/*.png');
|
if (requiresSpecialTreatment) {
|
||||||
return createSpritesStream('largeSprites', largeSrc);
|
let newWidth = dims.width < 90 ? 90 : dims.width;
|
||||||
});
|
let newHeight = dims.height < 90 ? 90 : dims.height;
|
||||||
|
dims = {
|
||||||
gulp.task('sprites:clean', (done) => {
|
width: newWidth,
|
||||||
clean(`${IMG_DIST_PATH}spritesmith*,${CSS_DIST_PATH}spritesmith*}`, done);
|
height: newHeight,
|
||||||
});
|
};
|
||||||
|
|
||||||
gulp.task('sprites:checkCompiledDimensions', ['sprites:main', 'sprites:largeSprites'], () => {
|
|
||||||
console.log('Verifiying that images do not exceed max dimensions');
|
|
||||||
|
|
||||||
let numberOfSheetsThatAreTooBig = 0;
|
|
||||||
|
|
||||||
let distSpritesheets = sync(`${IMG_DIST_PATH}*.png`);
|
|
||||||
|
|
||||||
each(distSpritesheets, (img, index) => {
|
|
||||||
let spriteSize = calculateImgDimensions(img);
|
|
||||||
|
|
||||||
if (spriteSize > MAX_SPRITESHEET_SIZE) {
|
|
||||||
numberOfSheetsThatAreTooBig++;
|
|
||||||
let name = basename(img, '.png');
|
|
||||||
console.error(`WARNING: ${name} might be too big - ${spriteSize} > ${MAX_SPRITESHEET_SIZE}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (numberOfSheetsThatAreTooBig > 0) {
|
|
||||||
console.error(`${numberOfSheetsThatAreTooBig} sheets might too big for mobile Safari to be able to handle them, but there is a margin of error in these calculations so it is probably okay. Mention this to an admin so they can test a staging site on mobile Safari after your PR is merged.`); // https://github.com/HabitRPG/habitica/pull/6683#issuecomment-185462180
|
|
||||||
} else {
|
|
||||||
console.log('All images are within the correct dimensions');
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
function createSpritesStream (name, src) {
|
let padding = 0;
|
||||||
let spritesheetSliceIndicies = calculateSpritesheetsSrcIndicies(src);
|
|
||||||
let stream = mergeStream();
|
|
||||||
|
|
||||||
each(spritesheetSliceIndicies, (start, index) => {
|
if (addPadding) {
|
||||||
let slicedSrc = src.slice(start, spritesheetSliceIndicies[index + 1]);
|
padding = dims.width * 8 + dims.height * 8;
|
||||||
|
}
|
||||||
|
|
||||||
let spriteData = gulp.src(slicedSrc)
|
if (!dims.width || !dims.height) console.error('MISSING DIMENSIONS:', dims); // eslint-disable-line no-console
|
||||||
.pipe(spritesmith({
|
|
||||||
imgName: `spritesmith-${name}-${index}.png`,
|
|
||||||
cssName: `spritesmith-${name}-${index}.css`,
|
|
||||||
algorithm: 'binary-tree',
|
|
||||||
padding: 1,
|
|
||||||
cssTemplate: 'website/raw_sprites/css/css.template.handlebars',
|
|
||||||
cssVarMap: cssVarMap,
|
|
||||||
}));
|
|
||||||
|
|
||||||
let imgStream = spriteData.img
|
let totalPixelSize = dims.width * dims.height + padding;
|
||||||
.pipe(imagemin())
|
|
||||||
.pipe(gulp.dest(IMG_DIST_PATH));
|
|
||||||
|
|
||||||
let cssStream = spriteData.css
|
return totalPixelSize;
|
||||||
.pipe(gulp.dest(CSS_DIST_PATH));
|
|
||||||
|
|
||||||
stream.add(imgStream);
|
|
||||||
stream.add(cssStream);
|
|
||||||
});
|
|
||||||
|
|
||||||
return stream;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateSpritesheetsSrcIndicies (src) {
|
function calculateSpritesheetsSrcIndicies (src) {
|
||||||
@@ -102,37 +62,6 @@ function calculateSpritesheetsSrcIndicies (src) {
|
|||||||
return slices;
|
return slices;
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateImgDimensions (img, addPadding) {
|
|
||||||
let dims = sizeOf(img);
|
|
||||||
|
|
||||||
let requiresSpecialTreatment = checkForSpecialTreatment(img);
|
|
||||||
if (requiresSpecialTreatment) {
|
|
||||||
let newWidth = dims.width < 90 ? 90 : dims.width;
|
|
||||||
let newHeight = dims.height < 90 ? 90 : dims.height;
|
|
||||||
dims = {
|
|
||||||
width: newWidth,
|
|
||||||
height: newHeight,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let padding = 0;
|
|
||||||
|
|
||||||
if (addPadding) {
|
|
||||||
padding = (dims.width * 8) + (dims.height * 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dims.width || !dims.height) console.error('MISSING DIMENSIONS:', dims);
|
|
||||||
|
|
||||||
let totalPixelSize = (dims.width * dims.height) + padding;
|
|
||||||
|
|
||||||
return totalPixelSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkForSpecialTreatment (name) {
|
|
||||||
let regex = /^hair|skin|beard|mustach|shirt|flower|^headAccessory_special_\w+Ears|^eyewear_special_\w+TopFrame/;
|
|
||||||
return name.match(regex) || name === 'head_0';
|
|
||||||
}
|
|
||||||
|
|
||||||
function cssVarMap (sprite) {
|
function cssVarMap (sprite) {
|
||||||
// For hair, skins, beards, etc. we want to output a '.customize-options.WHATEVER' class, which works as a
|
// For hair, skins, beards, etc. we want to output a '.customize-options.WHATEVER' class, which works as a
|
||||||
// 60x60 image pointing at the proper part of the 90x90 sprite.
|
// 60x60 image pointing at the proper part of the 90x90 sprite.
|
||||||
@@ -141,18 +70,93 @@ function cssVarMap (sprite) {
|
|||||||
if (requiresSpecialTreatment) {
|
if (requiresSpecialTreatment) {
|
||||||
sprite.custom = {
|
sprite.custom = {
|
||||||
px: {
|
px: {
|
||||||
offset_x: `-${ sprite.x + 25 }px`,
|
offsetX: `-${ sprite.x + 25 }px`,
|
||||||
offset_y: `-${ sprite.y + 15 }px`,
|
offsetY: `-${ sprite.y + 15 }px`,
|
||||||
width: '60px',
|
width: '60px',
|
||||||
height: '60px',
|
height: '60px',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (~sprite.name.indexOf('shirt'))
|
if (sprite.name.indexOf('shirt') !== -1)
|
||||||
sprite.custom.px.offset_y = `-${ sprite.y + 30 }px`; // even more for shirts
|
sprite.custom.px.offsetY = `-${ sprite.y + 30 }px`; // even more for shirts
|
||||||
if (~sprite.name.indexOf('hair_base')) {
|
if (sprite.name.indexOf('hair_base') !== -1) {
|
||||||
let styleArray = sprite.name.split('_').slice(2,3);
|
let styleArray = sprite.name.split('_').slice(2, 3);
|
||||||
if (Number(styleArray[0]) > 14)
|
if (Number(styleArray[0]) > 14)
|
||||||
sprite.custom.px.offset_y = `-${ sprite.y }px`; // don't crop updos
|
sprite.custom.px.offsetY = `-${ sprite.y }px`; // don't crop updos
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createSpritesStream (name, src) {
|
||||||
|
let spritesheetSliceIndicies = calculateSpritesheetsSrcIndicies(src);
|
||||||
|
let stream = mergeStream();
|
||||||
|
|
||||||
|
each(spritesheetSliceIndicies, (start, index) => {
|
||||||
|
let slicedSrc = src.slice(start, spritesheetSliceIndicies[index + 1]);
|
||||||
|
|
||||||
|
let spriteData = gulp.src(slicedSrc)
|
||||||
|
.pipe(spritesmith({
|
||||||
|
imgName: `spritesmith-${name}-${index}.png`,
|
||||||
|
cssName: `spritesmith-${name}-${index}.css`,
|
||||||
|
algorithm: 'binary-tree',
|
||||||
|
padding: 1,
|
||||||
|
cssTemplate: 'website/raw_sprites/css/css.template.handlebars',
|
||||||
|
cssVarMap,
|
||||||
|
}));
|
||||||
|
|
||||||
|
let imgStream = spriteData.img
|
||||||
|
.pipe(imagemin())
|
||||||
|
.pipe(gulp.dest(IMG_DIST_PATH));
|
||||||
|
|
||||||
|
let cssStream = spriteData.css
|
||||||
|
.pipe(gulp.dest(CSS_DIST_PATH));
|
||||||
|
|
||||||
|
stream.add(imgStream);
|
||||||
|
stream.add(cssStream);
|
||||||
|
});
|
||||||
|
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
gulp.task('sprites:compile', ['sprites:clean', 'sprites:main', 'sprites:largeSprites', 'sprites:checkCompiledDimensions']);
|
||||||
|
|
||||||
|
gulp.task('sprites:main', () => {
|
||||||
|
let mainSrc = sync('website/raw_sprites/spritesmith/**/*.png');
|
||||||
|
return createSpritesStream('main', mainSrc);
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('sprites:largeSprites', () => {
|
||||||
|
let largeSrc = sync('website/raw_sprites/spritesmith_large/**/*.png');
|
||||||
|
return createSpritesStream('largeSprites', largeSrc);
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('sprites:clean', (done) => {
|
||||||
|
clean(`${IMG_DIST_PATH}spritesmith*,${CSS_DIST_PATH}spritesmith*}`, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('sprites:checkCompiledDimensions', ['sprites:main', 'sprites:largeSprites'], () => {
|
||||||
|
console.log('Verifiying that images do not exceed max dimensions'); // eslint-disable-line no-console
|
||||||
|
|
||||||
|
let numberOfSheetsThatAreTooBig = 0;
|
||||||
|
|
||||||
|
let distSpritesheets = sync(`${IMG_DIST_PATH}*.png`);
|
||||||
|
|
||||||
|
each(distSpritesheets, (img) => {
|
||||||
|
let spriteSize = calculateImgDimensions(img);
|
||||||
|
|
||||||
|
if (spriteSize > MAX_SPRITESHEET_SIZE) {
|
||||||
|
numberOfSheetsThatAreTooBig++;
|
||||||
|
let name = basename(img, '.png');
|
||||||
|
console.error(`WARNING: ${name} might be too big - ${spriteSize} > ${MAX_SPRITESHEET_SIZE}`); // eslint-disable-line no-console
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (numberOfSheetsThatAreTooBig > 0) {
|
||||||
|
// https://github.com/HabitRPG/habitica/pull/6683#issuecomment-185462180
|
||||||
|
console.error( // eslint-disable-line no-console
|
||||||
|
`${numberOfSheetsThatAreTooBig} sheets might too big for mobile Safari to be able to handle
|
||||||
|
them, but there is a margin of error in these calculations so it is probably okay. Mention
|
||||||
|
this to an admin so they can test a staging site on mobile Safari after your PR is merged.`);
|
||||||
|
} else {
|
||||||
|
console.log('All images are within the correct dimensions'); // eslint-disable-line no-console
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,21 +1,12 @@
|
|||||||
import {
|
import {
|
||||||
pipe,
|
pipe,
|
||||||
awaitPort,
|
|
||||||
kill,
|
|
||||||
runMochaTests,
|
|
||||||
} from './taskHelper';
|
} from './taskHelper';
|
||||||
import { server as karma } from 'karma';
|
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
import psTree from 'ps-tree';
|
|
||||||
import gulp from 'gulp';
|
import gulp from 'gulp';
|
||||||
import Bluebird from 'bluebird';
|
|
||||||
import runSequence from 'run-sequence';
|
import runSequence from 'run-sequence';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import nconf from 'nconf';
|
import nconf from 'nconf';
|
||||||
import fs from 'fs';
|
|
||||||
|
|
||||||
const i18n = require('../website/server/libs/i18n');
|
|
||||||
|
|
||||||
// TODO rewrite
|
// TODO rewrite
|
||||||
|
|
||||||
@@ -24,7 +15,6 @@ let server;
|
|||||||
|
|
||||||
const TEST_DB_URI = nconf.get('TEST_DB_URI');
|
const TEST_DB_URI = nconf.get('TEST_DB_URI');
|
||||||
|
|
||||||
const API_V3_TEST_COMMAND = 'npm run test:api-v3';
|
|
||||||
const SANITY_TEST_COMMAND = 'npm run test:sanity';
|
const SANITY_TEST_COMMAND = 'npm run test:sanity';
|
||||||
const COMMON_TEST_COMMAND = 'npm run test:common';
|
const COMMON_TEST_COMMAND = 'npm run test:common';
|
||||||
const CONTENT_TEST_COMMAND = 'npm run test:content';
|
const CONTENT_TEST_COMMAND = 'npm run test:content';
|
||||||
@@ -34,14 +24,14 @@ const CONTENT_OPTIONS = {maxBuffer: 1024 * 500};
|
|||||||
let testResults = [];
|
let testResults = [];
|
||||||
let testCount = (stdout, regexp) => {
|
let testCount = (stdout, regexp) => {
|
||||||
let match = stdout.match(regexp);
|
let match = stdout.match(regexp);
|
||||||
return parseInt(match && match[1] || 0);
|
return parseInt(match && match[1] || 0, 10);
|
||||||
};
|
};
|
||||||
|
|
||||||
let testBin = (string, additionalEnvVariables = '') => {
|
let testBin = (string, additionalEnvVariables = '') => {
|
||||||
if (os.platform() === 'win32') {
|
if (os.platform() === 'win32') {
|
||||||
if (additionalEnvVariables != '') {
|
if (additionalEnvVariables !== '') {
|
||||||
additionalEnvVariables = additionalEnvVariables.split(' ').join('&&set ');
|
additionalEnvVariables = additionalEnvVariables.split(' ').join('&&set ');
|
||||||
additionalEnvVariables = 'set ' + additionalEnvVariables + '&&';
|
additionalEnvVariables = `set ${additionalEnvVariables}&&`;
|
||||||
}
|
}
|
||||||
return `set NODE_ENV=test&&${additionalEnvVariables}${string}`;
|
return `set NODE_ENV=test&&${additionalEnvVariables}${string}`;
|
||||||
} else {
|
} else {
|
||||||
@@ -49,9 +39,9 @@ let testBin = (string, additionalEnvVariables = '') => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
gulp.task('test:nodemon', (done) => {
|
gulp.task('test:nodemon', () => {
|
||||||
process.env.PORT = TEST_SERVER_PORT;
|
process.env.PORT = TEST_SERVER_PORT; // eslint-disable-line no-process-env
|
||||||
process.env.NODE_DB_URI = TEST_DB_URI;
|
process.env.NODE_DB_URI = TEST_DB_URI; // eslint-disable-line no-process-env
|
||||||
|
|
||||||
runSequence('nodemon');
|
runSequence('nodemon');
|
||||||
});
|
});
|
||||||
@@ -68,8 +58,12 @@ gulp.task('test:prepare:mongo', (cb) => {
|
|||||||
gulp.task('test:prepare:server', ['test:prepare:mongo'], () => {
|
gulp.task('test:prepare:server', ['test:prepare:mongo'], () => {
|
||||||
if (!server) {
|
if (!server) {
|
||||||
server = exec(testBin('node ./website/server/index.js', `NODE_DB_URI=${TEST_DB_URI} PORT=${TEST_SERVER_PORT}`), (error, stdout, stderr) => {
|
server = exec(testBin('node ./website/server/index.js', `NODE_DB_URI=${TEST_DB_URI} PORT=${TEST_SERVER_PORT}`), (error, stdout, stderr) => {
|
||||||
if (error) { throw `Problem with the server: ${error}`; }
|
if (error) {
|
||||||
if (stderr) { console.error(stderr); }
|
throw new Error(`Problem with the server: ${error}`);
|
||||||
|
}
|
||||||
|
if (stderr) {
|
||||||
|
console.error(stderr); // eslint-disable-line no-console
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -84,7 +78,7 @@ gulp.task('test:prepare', [
|
|||||||
gulp.task('test:sanity', (cb) => {
|
gulp.task('test:sanity', (cb) => {
|
||||||
let runner = exec(
|
let runner = exec(
|
||||||
testBin(SANITY_TEST_COMMAND),
|
testBin(SANITY_TEST_COMMAND),
|
||||||
(err, stdout, stderr) => {
|
(err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
@@ -97,7 +91,7 @@ gulp.task('test:sanity', (cb) => {
|
|||||||
gulp.task('test:common', ['test:prepare:build'], (cb) => {
|
gulp.task('test:common', ['test:prepare:build'], (cb) => {
|
||||||
let runner = exec(
|
let runner = exec(
|
||||||
testBin(COMMON_TEST_COMMAND),
|
testBin(COMMON_TEST_COMMAND),
|
||||||
(err, stdout, stderr) => {
|
(err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
@@ -118,7 +112,7 @@ gulp.task('test:common:watch', ['test:common:clean'], () => {
|
|||||||
gulp.task('test:common:safe', ['test:prepare:build'], (cb) => {
|
gulp.task('test:common:safe', ['test:prepare:build'], (cb) => {
|
||||||
let runner = exec(
|
let runner = exec(
|
||||||
testBin(COMMON_TEST_COMMAND),
|
testBin(COMMON_TEST_COMMAND),
|
||||||
(err, stdout, stderr) => {
|
(err, stdout) => { // eslint-disable-line handle-callback-err
|
||||||
testResults.push({
|
testResults.push({
|
||||||
suite: 'Common Specs\t',
|
suite: 'Common Specs\t',
|
||||||
pass: testCount(stdout, /(\d+) passing/),
|
pass: testCount(stdout, /(\d+) passing/),
|
||||||
@@ -135,7 +129,7 @@ gulp.task('test:content', ['test:prepare:build'], (cb) => {
|
|||||||
let runner = exec(
|
let runner = exec(
|
||||||
testBin(CONTENT_TEST_COMMAND),
|
testBin(CONTENT_TEST_COMMAND),
|
||||||
CONTENT_OPTIONS,
|
CONTENT_OPTIONS,
|
||||||
(err, stdout, stderr) => {
|
(err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
@@ -157,7 +151,7 @@ gulp.task('test:content:safe', ['test:prepare:build'], (cb) => {
|
|||||||
let runner = exec(
|
let runner = exec(
|
||||||
testBin(CONTENT_TEST_COMMAND),
|
testBin(CONTENT_TEST_COMMAND),
|
||||||
CONTENT_OPTIONS,
|
CONTENT_OPTIONS,
|
||||||
(err, stdout, stderr) => {
|
(err, stdout) => { // eslint-disable-line handle-callback-err
|
||||||
testResults.push({
|
testResults.push({
|
||||||
suite: 'Content Specs\t',
|
suite: 'Content Specs\t',
|
||||||
pass: testCount(stdout, /(\d+) passing/),
|
pass: testCount(stdout, /(\d+) passing/),
|
||||||
@@ -173,7 +167,7 @@ gulp.task('test:content:safe', ['test:prepare:build'], (cb) => {
|
|||||||
gulp.task('test:api-v3:unit', (done) => {
|
gulp.task('test:api-v3:unit', (done) => {
|
||||||
let runner = exec(
|
let runner = exec(
|
||||||
testBin('node_modules/.bin/istanbul cover --dir coverage/api-v3-unit --report lcovonly node_modules/mocha/bin/_mocha -- test/api/v3/unit --recursive --require ./test/helpers/start-server'),
|
testBin('node_modules/.bin/istanbul cover --dir coverage/api-v3-unit --report lcovonly node_modules/mocha/bin/_mocha -- test/api/v3/unit --recursive --require ./test/helpers/start-server'),
|
||||||
(err, stdout, stderr) => {
|
(err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
@@ -192,7 +186,7 @@ gulp.task('test:api-v3:integration', (done) => {
|
|||||||
let runner = exec(
|
let runner = exec(
|
||||||
testBin('node_modules/.bin/istanbul cover --dir coverage/api-v3-integration --report lcovonly node_modules/mocha/bin/_mocha -- test/api/v3/integration --recursive --require ./test/helpers/start-server'),
|
testBin('node_modules/.bin/istanbul cover --dir coverage/api-v3-integration --report lcovonly node_modules/mocha/bin/_mocha -- test/api/v3/integration --recursive --require ./test/helpers/start-server'),
|
||||||
{maxBuffer: 500 * 1024},
|
{maxBuffer: 500 * 1024},
|
||||||
(err, stdout, stderr) => {
|
(err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
@@ -212,7 +206,7 @@ gulp.task('test:api-v3:integration:separate-server', (done) => {
|
|||||||
let runner = exec(
|
let runner = exec(
|
||||||
testBin('mocha test/api/v3/integration --recursive --require ./test/helpers/start-server', 'LOAD_SERVER=0'),
|
testBin('mocha test/api/v3/integration --recursive --require ./test/helpers/start-server', 'LOAD_SERVER=0'),
|
||||||
{maxBuffer: 500 * 1024},
|
{maxBuffer: 500 * 1024},
|
||||||
(err, stdout, stderr) => done(err)
|
(err) => done(err)
|
||||||
);
|
);
|
||||||
|
|
||||||
pipe(runner);
|
pipe(runner);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import nconf from 'nconf';
|
|
||||||
import gulp from 'gulp';
|
import gulp from 'gulp';
|
||||||
import { postToSlack, conf } from './taskHelper';
|
import { postToSlack, conf } from './taskHelper';
|
||||||
|
|
||||||
@@ -12,8 +11,82 @@ const SLACK_CONFIG = {
|
|||||||
|
|
||||||
const LOCALES = './website/common/locales/';
|
const LOCALES = './website/common/locales/';
|
||||||
const ENGLISH_LOCALE = `${LOCALES}en/`;
|
const ENGLISH_LOCALE = `${LOCALES}en/`;
|
||||||
|
|
||||||
|
|
||||||
|
function getArrayOfLanguages () {
|
||||||
|
let languages = fs.readdirSync(LOCALES);
|
||||||
|
languages.shift(); // Remove README.md from array of languages
|
||||||
|
|
||||||
|
return languages;
|
||||||
|
}
|
||||||
|
|
||||||
const ALL_LANGUAGES = getArrayOfLanguages();
|
const ALL_LANGUAGES = getArrayOfLanguages();
|
||||||
|
|
||||||
|
function stripOutNonJsonFiles (collection) {
|
||||||
|
let onlyJson = _.filter(collection, (file) => {
|
||||||
|
return file.match(/[a-zA-Z]*\.json/);
|
||||||
|
});
|
||||||
|
|
||||||
|
return onlyJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
function eachTranslationFile (languages, cb) {
|
||||||
|
let jsonFiles = stripOutNonJsonFiles(fs.readdirSync(ENGLISH_LOCALE));
|
||||||
|
|
||||||
|
_.each(languages, (lang) => {
|
||||||
|
_.each(jsonFiles, (filename) => {
|
||||||
|
let parsedTranslationFile;
|
||||||
|
try {
|
||||||
|
const translationFile = fs.readFileSync(`${LOCALES}${lang}/${filename}`);
|
||||||
|
parsedTranslationFile = JSON.parse(translationFile);
|
||||||
|
} catch (err) {
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
let englishFile = fs.readFileSync(ENGLISH_LOCALE + filename);
|
||||||
|
let parsedEnglishFile = JSON.parse(englishFile);
|
||||||
|
|
||||||
|
cb(null, lang, filename, parsedEnglishFile, parsedTranslationFile);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function eachTranslationString (languages, cb) {
|
||||||
|
eachTranslationFile(languages, (error, language, filename, englishJSON, translationJSON) => {
|
||||||
|
if (error) return;
|
||||||
|
_.each(englishJSON, (string, key) => {
|
||||||
|
const translationString = translationJSON[key];
|
||||||
|
cb(language, filename, key, string, translationString);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatMessageForPosting (msg, items) {
|
||||||
|
let body = `*Warning:* ${msg}`;
|
||||||
|
body += '\n\n```\n';
|
||||||
|
body += items.join('\n');
|
||||||
|
body += '\n```';
|
||||||
|
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStringsWith (json, interpolationRegex) {
|
||||||
|
let strings = {};
|
||||||
|
|
||||||
|
_.each(json, (fileName) => {
|
||||||
|
const rawFile = fs.readFileSync(ENGLISH_LOCALE + fileName);
|
||||||
|
const parsedJson = JSON.parse(rawFile);
|
||||||
|
|
||||||
|
strings[fileName] = {};
|
||||||
|
_.each(parsedJson, (value, key) => {
|
||||||
|
const match = value.match(interpolationRegex);
|
||||||
|
if (match) strings[fileName][key] = match;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return strings;
|
||||||
|
}
|
||||||
|
|
||||||
const malformedStringExceptions = {
|
const malformedStringExceptions = {
|
||||||
messageDropFood: true,
|
messageDropFood: true,
|
||||||
armoireFood: true,
|
armoireFood: true,
|
||||||
@@ -23,7 +96,6 @@ const malformedStringExceptions = {
|
|||||||
gulp.task('transifex', ['transifex:missingFiles', 'transifex:missingStrings', 'transifex:malformedStrings']);
|
gulp.task('transifex', ['transifex:missingFiles', 'transifex:missingStrings', 'transifex:malformedStrings']);
|
||||||
|
|
||||||
gulp.task('transifex:missingFiles', () => {
|
gulp.task('transifex:missingFiles', () => {
|
||||||
|
|
||||||
let missingStrings = [];
|
let missingStrings = [];
|
||||||
|
|
||||||
eachTranslationFile(ALL_LANGUAGES, (error) => {
|
eachTranslationFile(ALL_LANGUAGES, (error) => {
|
||||||
@@ -40,7 +112,6 @@ gulp.task('transifex:missingFiles', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('transifex:missingStrings', () => {
|
gulp.task('transifex:missingStrings', () => {
|
||||||
|
|
||||||
let missingStrings = [];
|
let missingStrings = [];
|
||||||
|
|
||||||
eachTranslationString(ALL_LANGUAGES, (language, filename, key, englishString, translationString) => {
|
eachTranslationString(ALL_LANGUAGES, (language, filename, key, englishString, translationString) => {
|
||||||
@@ -58,7 +129,6 @@ gulp.task('transifex:missingStrings', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('transifex:malformedStrings', () => {
|
gulp.task('transifex:malformedStrings', () => {
|
||||||
|
|
||||||
let jsonFiles = stripOutNonJsonFiles(fs.readdirSync(ENGLISH_LOCALE));
|
let jsonFiles = stripOutNonJsonFiles(fs.readdirSync(ENGLISH_LOCALE));
|
||||||
let interpolationRegex = /<%= [a-zA-Z]* %>/g;
|
let interpolationRegex = /<%= [a-zA-Z]* %>/g;
|
||||||
let stringsToLookFor = getStringsWith(jsonFiles, interpolationRegex);
|
let stringsToLookFor = getStringsWith(jsonFiles, interpolationRegex);
|
||||||
@@ -66,25 +136,23 @@ gulp.task('transifex:malformedStrings', () => {
|
|||||||
let stringsWithMalformedInterpolations = [];
|
let stringsWithMalformedInterpolations = [];
|
||||||
let stringsWithIncorrectNumberOfInterpolations = [];
|
let stringsWithIncorrectNumberOfInterpolations = [];
|
||||||
|
|
||||||
let count = 0;
|
_.each(ALL_LANGUAGES, (lang) => {
|
||||||
_.each(ALL_LANGUAGES, function (lang) {
|
_.each(stringsToLookFor, (strings, filename) => {
|
||||||
|
let translationFile = fs.readFileSync(`${LOCALES}${lang}/${filename}`);
|
||||||
_.each(stringsToLookFor, function (strings, file) {
|
|
||||||
let translationFile = fs.readFileSync(LOCALES + lang + '/' + file);
|
|
||||||
let parsedTranslationFile = JSON.parse(translationFile);
|
let parsedTranslationFile = JSON.parse(translationFile);
|
||||||
|
|
||||||
_.each(strings, function (value, key) {
|
_.each(strings, (value, key) => { // eslint-disable-line max-nested-callbacks
|
||||||
let translationString = parsedTranslationFile[key];
|
let translationString = parsedTranslationFile[key];
|
||||||
if (!translationString) return;
|
if (!translationString) return;
|
||||||
|
|
||||||
let englishOccurences = stringsToLookFor[file][key];
|
let englishOccurences = stringsToLookFor[filename][key];
|
||||||
let translationOccurences = translationString.match(interpolationRegex);
|
let translationOccurences = translationString.match(interpolationRegex);
|
||||||
|
|
||||||
if (!translationOccurences) {
|
if (!translationOccurences) {
|
||||||
let malformedString = `${lang} - ${file} - ${key} - ${translationString}`;
|
let malformedString = `${lang} - ${filename} - ${key} - ${translationString}`;
|
||||||
stringsWithMalformedInterpolations.push(malformedString);
|
stringsWithMalformedInterpolations.push(malformedString);
|
||||||
} else if (englishOccurences.length !== translationOccurences.length && !malformedStringExceptions[key]) {
|
} else if (englishOccurences.length !== translationOccurences.length && !malformedStringExceptions[key]) {
|
||||||
let missingInterpolationString = `${lang} - ${file} - ${key} - ${translationString}`;
|
let missingInterpolationString = `${lang} - ${filename} - ${key} - ${translationString}`;
|
||||||
stringsWithIncorrectNumberOfInterpolations.push(missingInterpolationString);
|
stringsWithIncorrectNumberOfInterpolations.push(missingInterpolationString);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -103,74 +171,3 @@ gulp.task('transifex:malformedStrings', () => {
|
|||||||
postToSlack(formattedMessage, SLACK_CONFIG);
|
postToSlack(formattedMessage, SLACK_CONFIG);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function getArrayOfLanguages () {
|
|
||||||
let languages = fs.readdirSync(LOCALES);
|
|
||||||
languages.shift(); // Remove README.md from array of languages
|
|
||||||
|
|
||||||
return languages;
|
|
||||||
}
|
|
||||||
|
|
||||||
function eachTranslationFile (languages, cb) {
|
|
||||||
let jsonFiles = stripOutNonJsonFiles(fs.readdirSync(ENGLISH_LOCALE));
|
|
||||||
|
|
||||||
_.each(languages, (lang) => {
|
|
||||||
_.each(jsonFiles, (filename) => {
|
|
||||||
try {
|
|
||||||
var translationFile = fs.readFileSync(LOCALES + lang + '/' + filename);
|
|
||||||
var parsedTranslationFile = JSON.parse(translationFile);
|
|
||||||
} catch (err) {
|
|
||||||
return cb(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
let englishFile = fs.readFileSync(ENGLISH_LOCALE + filename);
|
|
||||||
let parsedEnglishFile = JSON.parse(englishFile);
|
|
||||||
|
|
||||||
cb(null, lang, filename, parsedEnglishFile, parsedTranslationFile);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function eachTranslationString (languages, cb) {
|
|
||||||
eachTranslationFile(languages, (error, language, filename, englishJSON, translationJSON) => {
|
|
||||||
if (error) return;
|
|
||||||
_.each(englishJSON, (string, key) => {
|
|
||||||
var translationString = translationJSON[key];
|
|
||||||
cb(language, filename, key, string, translationString);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatMessageForPosting (msg, items) {
|
|
||||||
let body = `*Warning:* ${msg}`;
|
|
||||||
body += '\n\n```\n';
|
|
||||||
body += items.join('\n');
|
|
||||||
body += '\n```';
|
|
||||||
|
|
||||||
return body;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getStringsWith (json, interpolationRegex) {
|
|
||||||
var strings = {};
|
|
||||||
|
|
||||||
_.each(json, function (file_name) {
|
|
||||||
var raw_file = fs.readFileSync(ENGLISH_LOCALE + file_name);
|
|
||||||
var parsed_json = JSON.parse(raw_file);
|
|
||||||
|
|
||||||
strings[file_name] = {};
|
|
||||||
_.each(parsed_json, function (value, key) {
|
|
||||||
var match = value.match(interpolationRegex);
|
|
||||||
if (match) strings[file_name][key] = match;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return strings;
|
|
||||||
}
|
|
||||||
|
|
||||||
function stripOutNonJsonFiles (collection) {
|
|
||||||
let onlyJson = _.filter(collection, (file) => {
|
|
||||||
return file.match(/[a-zA-Z]*\.json/);
|
|
||||||
});
|
|
||||||
|
|
||||||
return onlyJson;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { resolve } from 'path';
|
|||||||
* Get access to configruable values
|
* Get access to configruable values
|
||||||
*/
|
*/
|
||||||
nconf.argv().env().file({ file: 'config.json' });
|
nconf.argv().env().file({ file: 'config.json' });
|
||||||
export var conf = nconf;
|
export const conf = nconf;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Kill a child process and any sub-children that process may have spawned.
|
* Kill a child process and any sub-children that process may have spawned.
|
||||||
@@ -26,11 +26,12 @@ export function kill (proc) {
|
|||||||
pids.forEach(kill); return;
|
pids.forEach(kill); return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
exec(/^win/.test(process.platform)
|
exec(/^win/.test(process.platform) ?
|
||||||
? `taskkill /PID ${pid} /T /F`
|
`taskkill /PID ${pid} /T /F` :
|
||||||
: `kill -9 ${pid}`);
|
`kill -9 ${pid}`);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e); // eslint-disable-line no-console
|
||||||
}
|
}
|
||||||
catch (e) { console.log(e); }
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -44,21 +45,25 @@ export function kill (proc) {
|
|||||||
* before failing.
|
* before failing.
|
||||||
*/
|
*/
|
||||||
export function awaitPort (port, max = 60) {
|
export function awaitPort (port, max = 60) {
|
||||||
return new Bluebird((reject, resolve) => {
|
return new Bluebird((rej, res) => {
|
||||||
let socket, timeout, interval;
|
let socket;
|
||||||
|
let timeout;
|
||||||
|
let interval;
|
||||||
|
|
||||||
timeout = setTimeout(() => {
|
timeout = setTimeout(() => {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
reject(`Timed out after ${max} seconds`);
|
rej(`Timed out after ${max} seconds`);
|
||||||
}, max * 1000);
|
}, max * 1000);
|
||||||
|
|
||||||
interval = setInterval(() => {
|
interval = setInterval(() => {
|
||||||
socket = net.connect({port: port}, () => {
|
socket = net.connect({port}, () => {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
socket.destroy();
|
socket.destroy();
|
||||||
resolve();
|
res();
|
||||||
}).on('error', () => { socket.destroy; });
|
}).on('error', () => {
|
||||||
|
socket.destroy();
|
||||||
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -67,8 +72,12 @@ export function awaitPort (port, max = 60) {
|
|||||||
* Pipe the child's stdin and stderr to the parent process.
|
* Pipe the child's stdin and stderr to the parent process.
|
||||||
*/
|
*/
|
||||||
export function pipe (child) {
|
export function pipe (child) {
|
||||||
child.stdout.on('data', (data) => { process.stdout.write(data); });
|
child.stdout.on('data', (data) => {
|
||||||
child.stderr.on('data', (data) => { process.stderr.write(data); });
|
process.stdout.write(data);
|
||||||
|
});
|
||||||
|
child.stderr.on('data', (data) => {
|
||||||
|
process.stderr.write(data);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -78,8 +87,8 @@ export function postToSlack (msg, config = {}) {
|
|||||||
let slackUrl = nconf.get('SLACK_URL');
|
let slackUrl = nconf.get('SLACK_URL');
|
||||||
|
|
||||||
if (!slackUrl) {
|
if (!slackUrl) {
|
||||||
console.error('No slack post url specified. Your message was:');
|
console.error('No slack post url specified. Your message was:'); // eslint-disable-line no-console
|
||||||
console.log(msg);
|
console.log(msg); // eslint-disable-line no-console
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -89,15 +98,15 @@ export function postToSlack (msg, config = {}) {
|
|||||||
channel: `#${config.channel || '#general'}`,
|
channel: `#${config.channel || '#general'}`,
|
||||||
username: config.username || 'gulp task',
|
username: config.username || 'gulp task',
|
||||||
text: msg,
|
text: msg,
|
||||||
icon_emoji: `:${config.emoji || 'gulp'}:`,
|
icon_emoji: `:${config.emoji || 'gulp'}:`, // eslint-disable-line camelcase
|
||||||
})
|
})
|
||||||
.end((err, res) => {
|
.end((err) => {
|
||||||
if (err) console.error('Unable to post to slack', err);
|
if (err) console.error('Unable to post to slack', err); // eslint-disable-line no-console
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function runMochaTests (files, server, cb) {
|
export function runMochaTests (files, server, cb) {
|
||||||
require('../test/helpers/globals.helper');
|
require('../test/helpers/globals.helper'); // eslint-disable-line global-require
|
||||||
|
|
||||||
let mocha = new Mocha({reporter: 'spec'});
|
let mocha = new Mocha({reporter: 'spec'});
|
||||||
let tests = glob(files);
|
let tests = glob(files);
|
||||||
@@ -108,7 +117,7 @@ export function runMochaTests (files, server, cb) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mocha.run((numberOfFailures) => {
|
mocha.run((numberOfFailures) => {
|
||||||
if (!process.env.RUN_INTEGRATION_TEST_FOREVER) {
|
if (!process.env.RUN_INTEGRATION_TEST_FOREVER) { // eslint-disable-line no-process-env
|
||||||
if (server) kill(server);
|
if (server) kill(server);
|
||||||
process.exit(numberOfFailures);
|
process.exit(numberOfFailures);
|
||||||
}
|
}
|
||||||
|
|||||||
12
gulpfile.js
12
gulpfile.js
@@ -8,11 +8,11 @@
|
|||||||
|
|
||||||
require('babel-register');
|
require('babel-register');
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'production') {
|
if (process.env.NODE_ENV === 'production') { // eslint-disable-line no-process-env
|
||||||
require('./gulp/gulp-apidoc');
|
require('./gulp/gulp-apidoc'); // eslint-disable-line global-require
|
||||||
require('./gulp/gulp-build');
|
require('./gulp/gulp-build'); // eslint-disable-line global-require
|
||||||
require('./gulp/gulp-bootstrap');
|
require('./gulp/gulp-bootstrap'); // eslint-disable-line global-require
|
||||||
} else {
|
} else {
|
||||||
require('glob').sync('./gulp/gulp-*').forEach(require);
|
require('glob').sync('./gulp/gulp-*').forEach(require); // eslint-disable-line global-require
|
||||||
require('gulp').task('default', ['test']);
|
require('gulp').task('default', ['test']); // eslint-disable-line global-require
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user