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

lsif-npm

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lsif-npm - npm Package Compare versions

Comparing version 0.6.0-next.7 to 0.6.0-next.8

2

lib/common/writer.js

@@ -59,3 +59,3 @@ "use strict";

while (offset < buffer.length) {
offset += fs_1.writeSync(this.fd, buffer, offset);
offset += (0, fs_1.writeSync)(this.fd, buffer, offset);
}

@@ -62,0 +62,0 @@ }

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -280,97 +271,95 @@ exports.main = exports.run = void 0;

}
function run(options) {
return __awaiter(this, void 0, void 0, function* () {
if (options.help) {
return;
async function run(options) {
if (options.help) {
return;
}
if (options.version) {
console.log(require('../package.json').version);
return;
}
let packageFile = options.package;
if (packageFile === undefined) {
packageFile = 'package.json';
}
packageFile = paths.makeAbsolute(packageFile);
const packageJson = package_1.default.read(packageFile);
let projectRoot = options.projectRoot;
if (projectRoot === undefined && packageFile !== undefined) {
projectRoot = path.posix.dirname(packageFile);
if (!path.isAbsolute(projectRoot)) {
projectRoot = paths.makeAbsolute(projectRoot);
}
if (options.version) {
console.log(require('../package.json').version);
return;
}
if (projectRoot === undefined) {
console.error(`No project root specified.`);
process.exitCode = -1;
return;
}
if (!options.stdin && options.in === undefined) {
console.error(`Either a input file using --in or --stdin must be specified`);
process.exitCode = -1;
return;
}
if (!options.stdout && options.out === undefined) {
console.error(`Either a output file using --out or --stdout must be specified.`);
process.exitCode = -1;
return;
}
if (options.in !== undefined && options.out !== undefined && paths.makeAbsolute(options.in) === paths.makeAbsolute(options.out)) {
console.error(`Input and output file can't be the same.`);
process.exitCode = -1;
return;
}
let writer = new writer_1.StdoutWriter();
function emit(value) {
if (typeof value === 'string') {
writer.writeln(value);
}
let packageFile = options.package;
if (packageFile === undefined) {
packageFile = 'package.json';
else {
writer.writeln(JSON.stringify(value, undefined, 0));
}
packageFile = paths.makeAbsolute(packageFile);
const packageJson = package_1.default.read(packageFile);
let projectRoot = options.projectRoot;
if (projectRoot === undefined && packageFile !== undefined) {
projectRoot = path.posix.dirname(packageFile);
if (!path.isAbsolute(projectRoot)) {
projectRoot = paths.makeAbsolute(projectRoot);
}
}
const queue = new AttachQueue(emit);
const sourceInfo = new SourceInfo();
let exportLinker;
if (packageJson !== undefined) {
exportLinker = new ExportLinker(sourceInfo, packageJson, queue);
}
const importLinker = new ImportLinker(sourceInfo, queue);
let input = process.stdin;
if (options.in !== undefined && fs.existsSync(options.in)) {
input = fs.createReadStream(options.in, { encoding: 'utf8' });
}
if (options.out !== undefined) {
writer = new writer_1.FileWriter(fs.openSync(options.out, 'w'));
}
let needsInitialization = true;
let lastId;
const rd = readline.createInterface(input);
rd.on('line', (line) => {
emit(line);
let element = JSON.parse(line);
lastId = element.id;
if (needsInitialization) {
queue.initialize(element.id);
needsInitialization = false;
}
if (projectRoot === undefined) {
console.error(`No project root specified.`);
process.exitCode = -1;
return;
}
if (!options.stdin && options.in === undefined) {
console.error(`Either a input file using --in or --stdin must be specified`);
process.exitCode = -1;
return;
}
if (!options.stdout && options.out === undefined) {
console.error(`Either a output file using --out or --stdout must be specified.`);
process.exitCode = -1;
return;
}
if (options.in !== undefined && options.out !== undefined && paths.makeAbsolute(options.in) === paths.makeAbsolute(options.out)) {
console.error(`Input and output file can't be the same.`);
process.exitCode = -1;
return;
}
let writer = new writer_1.StdoutWriter();
function emit(value) {
if (typeof value === 'string') {
writer.writeln(value);
if (element.type === lsif_protocol_1.ElementTypes.vertex) {
switch (element.label) {
case lsif_protocol_1.VertexLabels.moniker:
if (exportLinker !== undefined) {
exportLinker.handleMoniker(element);
}
importLinker.handleMoniker(element);
break;
case lsif_protocol_1.VertexLabels.source:
sourceInfo.handleSource(element);
break;
}
else {
writer.writeln(JSON.stringify(value, undefined, 0));
}
}
const queue = new AttachQueue(emit);
const sourceInfo = new SourceInfo();
let exportLinker;
if (packageJson !== undefined) {
exportLinker = new ExportLinker(sourceInfo, packageJson, queue);
});
rd.on('close', () => {
if (lastId !== undefined) {
queue.flush(lastId);
}
const importLinker = new ImportLinker(sourceInfo, queue);
let input = process.stdin;
if (options.in !== undefined && fs.existsSync(options.in)) {
input = fs.createReadStream(options.in, { encoding: 'utf8' });
}
if (options.out !== undefined) {
writer = new writer_1.FileWriter(fs.openSync(options.out, 'w'));
}
let needsInitialization = true;
let lastId;
const rd = readline.createInterface(input);
rd.on('line', (line) => {
emit(line);
let element = JSON.parse(line);
lastId = element.id;
if (needsInitialization) {
queue.initialize(element.id);
needsInitialization = false;
}
if (element.type === lsif_protocol_1.ElementTypes.vertex) {
switch (element.label) {
case lsif_protocol_1.VertexLabels.moniker:
if (exportLinker !== undefined) {
exportLinker.handleMoniker(element);
}
importLinker.handleMoniker(element);
break;
case lsif_protocol_1.VertexLabels.source:
sourceInfo.handleSource(element);
break;
}
}
});
rd.on('close', () => {
if (lastId !== undefined) {
queue.flush(lastId);
}
});
});

@@ -387,3 +376,3 @@ }

wrap(Math.min(100, yargs.terminalWidth()));
const options = Object.assign({}, args_1.Options.defaults, args_1.builder(yargs).argv);
const options = Object.assign({}, args_1.Options.defaults, (0, args_1.builder)(yargs).argv);
return run(options);

@@ -390,0 +379,0 @@ }

@@ -50,3 +50,3 @@ "use strict";

}
catch (_a) {
catch {
}

@@ -53,0 +53,0 @@ return undefined;

{
"name": "lsif-npm",
"description": "A tools to rewrite Typescript LSIF monikers into npm monikers",
"version": "0.6.0-next.7",
"version": "0.6.0-next.8",
"author": "Microsoft Corporation",

@@ -20,6 +20,6 @@ "license": "MIT",

"dependencies": {
"lsif-protocol": "0.6.0-next.6",
"lsif-protocol": "0.6.0-next.7",
"uuid": "^8.3.2",
"vscode-uri": "^3.0.2",
"yargs": "16.2.0"
"yargs": "^17.2.1"
},

@@ -26,0 +26,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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