[docker] update grammar

This commit is contained in:
Martin Aeschlimann 2017-05-25 09:24:50 +02:00 committed by Dirk Baeumer
parent 51a10b5ebe
commit d264b70f20
3 changed files with 26 additions and 13 deletions

View file

@ -25,19 +25,28 @@ function getOptions(urlString) {
}
}
function download(url) {
return new Promise((c, e) => {
var content = '';
var request = https.get(getOptions(url), function (response) {
function download(url, redirectCount) {
return new Promise((c, e) => {
var content = '';
https.get(getOptions(url), function (response) {
response.on('data', function (data) {
content += data.toString();
}).on('end', function () {
let count = redirectCount || 0;
if (count < 5 && response.statusCode >= 300 && response.statusCode <= 303 || response.statusCode === 307) {
let location = response.headers['location'];
if (location) {
console.log("Redirected " + url + " to " + location);
download(location, count+1).then(c, e);
return;
}
}
c(content);
});
}).on('error', function (err) {
e(err.message);
});
});
});
}
function getCommitSha(repoId, repoPath) {
@ -46,14 +55,15 @@ function getCommitSha(repoId, repoPath) {
try {
let lastCommit = JSON.parse(content)[0];
return Promise.resolve({
commitSha : lastCommit.sha,
commitDate : lastCommit.commit.author.date
commitSha: lastCommit.sha,
commitDate: lastCommit.commit.author.date
});
} catch (e) {
console.error("Failed extracting the SHA: " + content);
return Promise.resolve(null);
}
}, function () {
console.err('Failed loading ' + commitInfo);
console.error('Failed loading ' + commitInfo);
return Promise.resolve(null);
});
}
@ -97,7 +107,7 @@ exports.update = function (repoId, repoPath, dest, modifyGrammar) {
}
if (path.basename(process.argv[1]) === 'update-grammar.js') {
for (var i = 3; i < process.argv.length; i+=2) {
exports.update(process.argv[2], process.argv[i], process.argv[i+1]);
for (var i = 3; i < process.argv.length; i += 2) {
exports.update(process.argv[2], process.argv[i], process.argv[i + 1]);
}
}

View file

@ -4,7 +4,7 @@
"publisher": "vscode",
"engines": { "vscode": "*" },
"scripts": {
"update-grammar": "node ../../build/npm/update-grammar.js docker/docker contrib/syntax/textmate/Docker.tmbundle/Syntaxes/Dockerfile.tmLanguage ./syntaxes/docker.tmLanguage.json"
"update-grammar": "node ../../build/npm/update-grammar.js moby/moby contrib/syntax/textmate/Docker.tmbundle/Syntaxes/Dockerfile.tmLanguage ./syntaxes/docker.tmLanguage.json"
},
"contributes": {
"languages": [{

View file

@ -8,9 +8,12 @@
"captures": {
"1": {
"name": "keyword.other.special-method.dockerfile"
},
"2": {
"name": "keyword.other.special-method.dockerfile"
}
},
"match": "\\s*(?:(FROM|AS))\\s"
"match": "^\\s*\\b(FROM)\\b.*?\\b(AS)\\b"
},
{
"captures": {
@ -94,5 +97,5 @@
],
"scopeName": "source.dockerfile",
"uuid": "a39d8795-59d2-49af-aa00-fe74ee29576e",
"version": "https://github.com/moby/moby/commit/4cb71f80823af345d063cf0ad657e73ce9caa75f"
"version": "https://github.com/moby/moby/commit/8523e9d108a0e98865673701a7bd0a7929c5260b"
}