mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-02-18 09:00:30 -05:00
Lint bin subdirectories
This commit is contained in:
parent
eb5edc293d
commit
303b5c44a8
4 changed files with 24 additions and 37 deletions
2
Makefile
2
Makefile
|
@ -68,7 +68,7 @@ test:
|
||||||
lint:
|
lint:
|
||||||
$(ESLINT) ./*.js
|
$(ESLINT) ./*.js
|
||||||
$(ESLINT) ./dev-server/*.js
|
$(ESLINT) ./dev-server/*.js
|
||||||
$(ESLINT) ./bin/**.js
|
$(ESLINT) ./bin/**/*.js
|
||||||
$(ESLINT) ./src/*.js
|
$(ESLINT) ./src/*.js
|
||||||
$(ESLINT) ./src/mixins/*.jsx
|
$(ESLINT) ./src/mixins/*.jsx
|
||||||
$(ESLINT) ./src/views/**/*.jsx
|
$(ESLINT) ./src/views/**/*.jsx
|
||||||
|
|
|
@ -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
|
* Combine static paths, routes, and any additional paths to a single
|
||||||
* fastly condition to match req.url
|
* fastly condition to match req.url
|
||||||
|
@ -114,7 +121,7 @@ async.auto({
|
||||||
passRequestCondition: ['version', 'notPassRequestCondition', function (cb, results) {
|
passRequestCondition: ['version', 'notPassRequestCondition', function (cb, results) {
|
||||||
var condition = {
|
var condition = {
|
||||||
name: PASS_REQUEST_CONDITION_NAME,
|
name: PASS_REQUEST_CONDITION_NAME,
|
||||||
statement: fastly.negateConditionStatement(results.notPassRequestCondition.statement),
|
statement: negateConditionStatement(results.notPassRequestCondition.statement),
|
||||||
type: 'REQUEST',
|
type: 'REQUEST',
|
||||||
priority: 10
|
priority: 10
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,18 +11,6 @@ module.exports = function (apiKey, serviceId) {
|
||||||
var fastly = Fastly(apiKey);
|
var fastly = Fastly(apiKey);
|
||||||
fastly.serviceId = serviceId;
|
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
|
* Helper method for constructing Fastly API urls
|
||||||
*
|
*
|
||||||
|
@ -42,14 +30,12 @@ module.exports = function (apiKey, serviceId) {
|
||||||
*/
|
*/
|
||||||
fastly.getLatestVersion = function (cb) {
|
fastly.getLatestVersion = function (cb) {
|
||||||
if (!this.serviceId) {
|
if (!this.serviceId) {
|
||||||
console.error('Failed to get latest version.');
|
return cb('Failed to get latest version. No serviceId configured');
|
||||||
return cb('No serviceId configured');
|
|
||||||
}
|
}
|
||||||
var url = '/service/'+ encodeURIComponent(this.serviceId) +'/version';
|
var url = '/service/'+ encodeURIComponent(this.serviceId) +'/version';
|
||||||
this.request('GET', url, function (err, versions) {
|
this.request('GET', url, function (err, versions) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error('Failed to get versions', err);
|
return cb('Failed to fetch versions: ' + err);
|
||||||
return cb(err);
|
|
||||||
}
|
}
|
||||||
var latestVersion = versions.reduce(function (latestVersion, version) {
|
var latestVersion = versions.reduce(function (latestVersion, version) {
|
||||||
if (!latestVersion) return version;
|
if (!latestVersion) return version;
|
||||||
|
@ -70,8 +56,7 @@ module.exports = function (apiKey, serviceId) {
|
||||||
*/
|
*/
|
||||||
fastly.setCondition = function (version, condition, cb) {
|
fastly.setCondition = function (version, condition, cb) {
|
||||||
if (!this.serviceId) {
|
if (!this.serviceId) {
|
||||||
console.error('Failed to set condition', condition);
|
return cb('Failed to set condition. No serviceId configured');
|
||||||
return cb('No serviceId configured');
|
|
||||||
}
|
}
|
||||||
var name = condition.name;
|
var name = condition.name;
|
||||||
var putUrl = this.getFastlyAPIPrefix(this.serviceId, version) + '/condition/' + encodeURIComponent(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) {
|
if (err && err.statusCode === 404) {
|
||||||
this.request('POST', postUrl, condition, function (err, response) {
|
this.request('POST', postUrl, condition, function (err, response) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('Failed to POST header', header);
|
return cb('Failed while inserting condition: ' + err);
|
||||||
return cb(err);
|
|
||||||
}
|
}
|
||||||
return cb(null, response);
|
return cb(null, response);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error('Failed to PUT condition', condition);
|
return cb('Failed to update condition: ' + err);
|
||||||
return cb(err);
|
|
||||||
}
|
}
|
||||||
return cb(null, response);
|
return cb(null, response);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
@ -105,8 +88,7 @@ module.exports = function (apiKey, serviceId) {
|
||||||
*/
|
*/
|
||||||
fastly.setFastlyHeader = function (version, header, cb) {
|
fastly.setFastlyHeader = function (version, header, cb) {
|
||||||
if (!this.serviceId) {
|
if (!this.serviceId) {
|
||||||
console.error('Failed to set header', header);
|
cb('Failed to set header. No serviceId configured');
|
||||||
cb('No serviceId configured');
|
|
||||||
}
|
}
|
||||||
var name = header.name;
|
var name = header.name;
|
||||||
var putUrl = this.getFastlyAPIPrefix(this.serviceId, version) + '/header/' + encodeURIComponent(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) {
|
if (err && err.statusCode === 404) {
|
||||||
this.request('POST', postUrl, header, function (err, response) {
|
this.request('POST', postUrl, header, function (err, response) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error('Failed to POST header', header);
|
return cb('Failed to insert header: ' + err);
|
||||||
return cb(err);
|
|
||||||
}
|
}
|
||||||
return cb(null, response);
|
return cb(null, response);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error('Failed to PUT header', header);
|
return cb('Failed to update header: ' + err);
|
||||||
return cb(err);
|
|
||||||
}
|
}
|
||||||
return cb(null, response);
|
return cb(null, response);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
|
@ -38,8 +38,8 @@ Helpers.mergeNewTranslations = function (existingTranslations, newTranslations,
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fill in defaults
|
//Fill in defaults
|
||||||
for (var id in icuTemplate) {
|
for (var icuId in icuTemplate) {
|
||||||
if (!existingTranslations.hasOwnProperty(id)) existingTranslations[id] = icuTemplate[id];
|
if (!existingTranslations.hasOwnProperty(icuId)) existingTranslations[icuId] = icuTemplate[icuId];
|
||||||
}
|
}
|
||||||
return existingTranslations;
|
return existingTranslations;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue