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.2.5 to 0.2.6

README.md

10

lib/main.d.ts

@@ -1,11 +0,1 @@

import * as minimist from 'minimist';
interface Options extends minimist.ParsedArgs {
package?: string;
projectRoot?: string;
file?: string;
}
export declare namespace Options {
const defaults: Options;
}
export declare function main(): void;
export {};

56

lib/main.js

@@ -23,3 +23,4 @@ "use strict";

Options.defaults = {
_: [],
help: false,
version: false,
package: undefined,

@@ -29,3 +30,10 @@ projectRoot: undefined,

};
})(Options = exports.Options || (exports.Options = {}));
Options.descriptions = [
{ id: 'version', type: 'boolean', alias: 'v', default: false, description: 'output the version number' },
{ id: 'help', type: 'boolean', alias: 'h', default: false, description: 'output usage information' },
{ id: 'package', type: 'string', default: undefined, description: 'Specifies the location of the package.json file to use. Defaults to the package.json in the current directory.' },
{ id: 'projectRoot', type: 'string', default: undefined, description: 'Specifies the project root. Defaults to the location of the [tj]sconfig.json file.' },
{ id: 'file', type: 'string', default: undefined, description: 'Specifies the file that contains a LSIF dump. Defaults to stdin.' },
];
})(Options || (Options = {}));
function emit(value) {

@@ -202,7 +210,41 @@ if (Is.string(value)) {

function main() {
let options = Object.assign(Options.defaults, minimist(process.argv.slice(2), {
string: [
'package', 'projectRoot', 'file',
]
}));
let minOpts = {
string: [],
boolean: [],
default: Object.create(null),
alias: Object.create(null)
};
let longestId = 0;
for (let description of Options.descriptions) {
longestId = Math.max(longestId, description.id.length);
minOpts[description.type] = description.id;
minOpts.default[description.id] = description.default;
if (description.alias !== undefined) {
minOpts.alias[description.id] = [description.alias];
}
}
const options = Object.assign(Options.defaults, minimist(process.argv.slice(2), minOpts));
if (options.version) {
console.log(require('../package.json').version);
return;
}
let buffer = [];
if (options.help) {
buffer.push(`Languag Server Index Format tool for NPM`);
buffer.push(`Version: ${require('../package.json').version}`);
buffer.push('');
buffer.push(`Usage: lsif-npm [options]`);
buffer.push('');
buffer.push(`Options`);
for (let description of Options.descriptions) {
if (description.alias !== undefined) {
buffer.push(` -${description.alias} --${description.id}${' '.repeat(longestId - description.id.length)} ${description.description}`);
}
else {
buffer.push(` --${description.id} ${' '.repeat(longestId - description.id.length)} ${description.description}`);
}
}
console.log(buffer.join('\n'));
return;
}
let packageFile = options.package;

@@ -209,0 +251,0 @@ if (packageFile === undefined) {

{
"name": "lsif-npm",
"description": "A tools to rewrite Typescript LSIF monikers into npm monikers",
"version": "0.2.5",
"version": "0.2.6",
"author": "Microsoft Corporation",

@@ -23,3 +23,3 @@ "license": "MIT",

"lsif-protocol": "0.2.3",
"lsif-tsc": "0.2.5"
"lsif-tsc": "0.2.6"
},

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

@@ -27,3 +27,5 @@ /* --------------------------------------------------------------------------------------------

interface Options extends minimist.ParsedArgs {
interface Options {
help: boolean;
version: boolean;
package?: string;

@@ -34,5 +36,15 @@ projectRoot?: string;

export namespace Options {
interface OptionDescription {
id: keyof Options;
type: 'boolean' | 'string';
alias?: string;
default: any;
values?: string[];
description: string;
}
namespace Options {
export const defaults: Options = {
_: [],
help: false,
version: false,
package: undefined,

@@ -42,2 +54,9 @@ projectRoot: undefined,

};
export const descriptions: OptionDescription[] = [
{ id: 'version', type: 'boolean', alias: 'v', default: false, description: 'output the version number'},
{ id: 'help', type: 'boolean', alias: 'h', default: false, description: 'output usage information'},
{ id: 'package', type: 'string', default: undefined, description: 'Specifies the location of the package.json file to use. Defaults to the package.json in the current directory.'},
{ id: 'projectRoot', type: 'string', default: undefined, description: 'Specifies the project root. Defaults to the location of the [tj]sconfig.json file.'},
{ id: 'file', type: 'string', default: undefined, description: 'Specifies the file that contains a LSIF dump. Defaults to stdin.'},
];
}

@@ -234,7 +253,47 @@

export function main(): void {
let options: Options = Object.assign(Options.defaults, minimist(process.argv.slice(2), {
string: [
'package', 'projectRoot', 'file',
]
}));
let minOpts: minimist.Opts = {
string: [],
boolean: [],
default: Object.create(null),
alias: Object.create(null)
};
let longestId: number = 0;
for (let description of Options.descriptions) {
longestId = Math.max(longestId, description.id.length);
minOpts[description.type] = description.id;
minOpts.default![description.id] = description.default;
if (description.alias !== undefined) {
minOpts.alias![description.id] = [description.alias];
}
}
const options: Options = Object.assign(Options.defaults, minimist(process.argv.slice(2), minOpts));
if (options.version) {
console.log(require('../package.json').version);
return;
}
let buffer: string[] = [];
if (options.help) {
buffer.push(`Languag Server Index Format tool for NPM`);
buffer.push(`Version: ${require('../package.json').version}`);
buffer.push('');
buffer.push(`Usage: lsif-npm [options]`);
buffer.push('');
buffer.push(`Options`);
for (let description of Options.descriptions) {
if (description.alias !== undefined) {
buffer.push(` -${description.alias} --${description.id}${' '.repeat(longestId - description.id.length)} ${description.description}`);
} else {
buffer.push(` --${description.id} ${' '.repeat(longestId - description.id.length)} ${description.description}`);
}
}
console.log(buffer.join('\n'));
return;
}
let packageFile: string | undefined = options.package;

@@ -241,0 +300,0 @@ if (packageFile === undefined) {

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