Lint bin subdirectories

This commit is contained in:
Ray Schamp 2016-04-19 10:47:33 -04:00
parent eb5edc293d
commit 303b5c44a8
4 changed files with 24 additions and 37 deletions

View file

@ -68,7 +68,7 @@ test:
lint:
$(ESLINT) ./*.js
$(ESLINT) ./dev-server/*.js
$(ESLINT) ./bin/**.js
$(ESLINT) ./bin/**/*.js
$(ESLINT) ./src/*.js
$(ESLINT) ./src/mixins/*.jsx
$(ESLINT) ./src/views/**/*.jsx

View file

@ -59,6 +59,13 @@ var pathsToCondition = function (paths) {
}, '');
};
/*
* Helper method to NOT a condition statement
*/
var negateConditionStatement = function (statement) {
return '!(' + statement + ')';
};
/*
* Combine static paths, routes, and any additional paths to a single
* fastly condition to match req.url
@ -114,7 +121,7 @@ async.auto({
passRequestCondition: ['version', 'notPassRequestCondition', function (cb, results) {
var condition = {
name: PASS_REQUEST_CONDITION_NAME,
statement: fastly.negateConditionStatement(results.notPassRequestCondition.statement),
statement: negateConditionStatement(results.notPassRequestCondition.statement),
type: 'REQUEST',
priority: 10
};

View file

@ -11,18 +11,6 @@ module.exports = function (apiKey, serviceId) {
var fastly = Fastly(apiKey);
fastly.serviceId = serviceId;
/*
* Helper method to NOT a condition statement
*
* @param {string} Statement
*
* @return {string}
*/
fastly.negateConditionStatement = function (statement) {
return '!(' + statement + ')';
};
/*
* Helper method for constructing Fastly API urls
*
@ -42,14 +30,12 @@ module.exports = function (apiKey, serviceId) {
*/
fastly.getLatestVersion = function (cb) {
if (!this.serviceId) {
console.error('Failed to get latest version.');
return cb('No serviceId configured');
return cb('Failed to get latest version. No serviceId configured');
}
var url = '/service/'+ encodeURIComponent(this.serviceId) +'/version';
this.request('GET', url, function (err, versions) {
if (err) {
console.error('Failed to get versions', err);
return cb(err);
return cb('Failed to fetch versions: ' + err);
}
var latestVersion = versions.reduce(function (latestVersion, version) {
if (!latestVersion) return version;
@ -70,8 +56,7 @@ module.exports = function (apiKey, serviceId) {
*/
fastly.setCondition = function (version, condition, cb) {
if (!this.serviceId) {
console.error('Failed to set condition', condition);
return cb('No serviceId configured');
return cb('Failed to set condition. No serviceId configured');
}
var name = condition.name;
var putUrl = this.getFastlyAPIPrefix(this.serviceId, version) + '/condition/' + encodeURIComponent(name);
@ -80,16 +65,14 @@ module.exports = function (apiKey, serviceId) {
if (err && err.statusCode === 404) {
this.request('POST', postUrl, condition, function (err, response) {
if (err) {
console.log('Failed to POST header', header);
return cb(err);
return cb('Failed while inserting condition: ' + err);
}
return cb(null, response);
});
return;
}
if (err) {
console.error('Failed to PUT condition', condition);
return cb(err);
return cb('Failed to update condition: ' + err);
}
return cb(null, response);
}.bind(this));
@ -105,8 +88,7 @@ module.exports = function (apiKey, serviceId) {
*/
fastly.setFastlyHeader = function (version, header, cb) {
if (!this.serviceId) {
console.error('Failed to set header', header);
cb('No serviceId configured');
cb('Failed to set header. No serviceId configured');
}
var name = header.name;
var putUrl = this.getFastlyAPIPrefix(this.serviceId, version) + '/header/' + encodeURIComponent(name);
@ -115,16 +97,14 @@ module.exports = function (apiKey, serviceId) {
if (err && err.statusCode === 404) {
this.request('POST', postUrl, header, function (err, response) {
if (err) {
console.error('Failed to POST header', header);
return cb(err);
return cb('Failed to insert header: ' + err);
}
return cb(null, response);
});
return;
}
if (err) {
console.error('Failed to PUT header', header);
return cb(err);
return cb('Failed to update header: ' + err);
}
return cb(null, response);
}.bind(this));

View file

@ -38,8 +38,8 @@ Helpers.mergeNewTranslations = function (existingTranslations, newTranslations,
}
//Fill in defaults
for (var id in icuTemplate) {
if (!existingTranslations.hasOwnProperty(id)) existingTranslations[id] = icuTemplate[id];
for (var icuId in icuTemplate) {
if (!existingTranslations.hasOwnProperty(icuId)) existingTranslations[icuId] = icuTemplate[icuId];
}
return existingTranslations;
};