提交 893483c9 编写于 作者: M Martin Aeschlimann

[typescript] grammar-update script

上级 fe8bb5b4
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
var https = require('https');
var fs = require('fs');
var url = require('url');
function getOptions(urlString) {
var _url = url.parse(urlString);
return {
host: _url.host,
port: _url.port,
path: _url.pathname,
headers: {
'User-Agent': 'NodeJS'
}
}
}
exports.toFile = function (url, dest) {
return new Promise((c, e) => {
var file = fs.createWriteStream(dest);
var request = https.get(getOptions(url), function (response) {
response.pipe(file);
file.on('finish', function () {
var cb = (err, result) => err ? e(err) : c(result);
file.close(cb);
});
}).on('error', function (err) { // Handle errors
fs.unlink(dest); // Delete the file async, don't check the result
e(err.message);
});
});
};
exports.toString = function(url) {
return new Promise((c, e) => {
var content = '';
var request = https.get(getOptions(url), function (response) {
response.on('data', function (data) {
content += data.toString();
}).on('end', function () {
c(content);
});
}).on('error', function (err) {
e(err.message);
});
});
}
\ No newline at end of file
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
var download = require('../../../build/lib/download');
var fs = require('fs');
var contentBaseLocation = 'https://raw.githubusercontent.com/Microsoft/TypeScript-TmLanguage/master/';
var lastCommit = 'https://api.github.com/repos/Microsoft/TypeScript-TmLanguage/git/refs/heads/master';
Promise.all([
download.toFile(contentBaseLocation + 'TypeScript.tmLanguage', './syntaxes/TypeScript.tmLanguage'),
download.toFile(contentBaseLocation + 'TypeScriptReact.tmLanguage', './syntaxes/TypeScriptReact.tmLanguage'),
download.toString(lastCommit).then(function (content) {
fs.writeFileSync('./syntaxes/grammar-version.txt', JSON.parse(content).object.url);
console.log('Update completed.')
}, console.error)
]);
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
"vscode-nls": "^1.0.4" "vscode-nls": "^1.0.4"
}, },
"scripts": { "scripts": {
"vscode:prepublish": "node ../../node_modules/gulp/bin/gulp.js --gulpfile ../../build/gulpfile.extensions.js compile-extension:typescript ./tsconfig.json" "vscode:prepublish": "node ../../node_modules/gulp/bin/gulp.js --gulpfile ../../build/gulpfile.extensions.js compile-extension:typescript ./tsconfig.json",
"update-grammar": "node ./build/update-grammars.js"
}, },
"activationEvents": [ "activationEvents": [
"onLanguage:javascript", "onLanguage:javascript",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册