Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vscode-grammar-updater

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vscode-grammar-updater - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

8

bin.js

@@ -0,1 +1,3 @@

#!/usr/bin/env node
/*---------------------------------------------------------------------------------------------

@@ -5,10 +7,10 @@ * Copyright (c) Microsoft Corporation. All rights reserved.

*--------------------------------------------------------------------------------------------*/
const grammarImporter = require('./');
const grammarUpdater = require('./');
if (process.argv.length <= 2) {
console.log('Usage: vscode-grammar-importer repoName (repoPath destinationPath)+');
console.log('Usage: vscode-grammar-updater repoName (repoPath destinationPath)+');
return;
}
for (var i = 3; i < process.argv.length; i += 2) {
grammarImporter.update(process.argv[2], process.argv[i], process.argv[i + 1]);
grammarUpdater.update(process.argv[2], process.argv[i], process.argv[i + 1]);
}

@@ -124,4 +124,6 @@ /*---------------------------------------------------------------------------------------------

try {
fs.writeFileSync(dest, JSON.stringify(result, null, '\t').replace(/\n/g, '\r\n'));
let cgmanifestRead = JSON.parse(fs.readFileSync('./cgmanifest.json').toString());
const eol = getEOLFromPath(dest);
fs.writeFileSync(dest, JSON.stringify(result, null, '\t').replace(/\n/g, eol));
let cgmanifestContent = fs.readFileSync('./cgmanifest.json').toString();
let cgmanifestRead = JSON.parse(cgmanifestContent);
let promises = new Array();

@@ -140,12 +142,12 @@ const currentCommitDate = info.commitDate.substr(0, 10);

cgmanifestRead.registrations[i].component.git.commitHash = info.commitSha;
commitDate = currentCommitDate;
promises.push(download(packageJsonPath).then(function (packageJson) {
if (packageJson) {
try {
cgmanifestRead.registrations[i].version = JSON.parse(packageJson).version;
} catch (e) {
console.log('Cannot get version. File does not exist at ' + packageJsonPath);
}
commitDate = currentCommitDate;
promises.push(download(packageJsonPath).then(function (packageJson) {
if (packageJson) {
try {
cgmanifestRead.registrations[i].version = JSON.parse(packageJson).version;
} catch (e) {
console.log('Cannot get version. File does not exist at ' + packageJsonPath);
}
}));
}
}));
break;

@@ -155,4 +157,6 @@ }

}
Promise.all(promises).then(function (allResult) {
fs.writeFileSync('./cgmanifest.json', JSON.stringify(cgmanifestRead, null, '\t').replace(/\n/g, '\r\n'));
const eol = getExistingEOL(cgmanifestContent);
fs.writeFileSync('./cgmanifest.json', JSON.stringify(cgmanifestRead, null, '\t').replace(/\n/g, eol));
});

@@ -175,1 +179,28 @@ if (info) {

const CharCode_LF = 10;
const CharCode_CR = 13;
const DEFAULT_EOL = '\r\n';
function getExistingEOL(content) {
for (let i = 0; i < content.length; i++) {
const ch = content.charCodeAt(i);
if (ch === CharCode_CR) {
if (i + 1 < content.length && content.charCodeAt(i + 1) == CharCode_LF) {
return '\r\n';
}
return '\r';
} else if (ch === CharCode_LF) {
return '\n';
}
}
return DEFAULT_EOL;
}
function getEOLFromPath(dest) {
try {
return getExistingEOL(fs.readFileSync(dest).toString());
} catch (e) {
return DEFAULT_EOL;
}
}
{
"name": "vscode-grammar-updater",
"version": "1.0.0",
"description": "Utility to import TextMate grammars into VSCode language extensions",
"version": "1.0.1",
"description": "Utility to update TextMate grammars that are part of VSCode language extensions",
"main": "./index.js",

@@ -6,0 +6,0 @@ "bin": "./bin.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc