Comparing version 0.6.0-next.6 to 0.6.0-next.7
import { Options } from './args'; | ||
export declare function run(options: Options): void; | ||
export declare function main(): void; | ||
export declare function run(options: Options): Promise<void>; | ||
export declare function main(): Promise<void>; |
181
lib/main.js
"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 }); | ||
@@ -272,94 +281,96 @@ exports.main = exports.run = void 0; | ||
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); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (options.help) { | ||
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); | ||
if (options.version) { | ||
console.log(require('../package.json').version); | ||
return; | ||
} | ||
else { | ||
writer.writeln(JSON.stringify(value, undefined, 0)); | ||
let packageFile = options.package; | ||
if (packageFile === undefined) { | ||
packageFile = 'package.json'; | ||
} | ||
} | ||
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; | ||
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 (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; | ||
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); | ||
} | ||
else { | ||
writer.writeln(JSON.stringify(value, undefined, 0)); | ||
} | ||
} | ||
}); | ||
rd.on('close', () => { | ||
if (lastId !== undefined) { | ||
queue.flush(lastId); | ||
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 (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); | ||
} | ||
}); | ||
}); | ||
@@ -366,0 +377,0 @@ } |
{ | ||
"name": "lsif-npm", | ||
"description": "A tools to rewrite Typescript LSIF monikers into npm monikers", | ||
"version": "0.6.0-next.6", | ||
"version": "0.6.0-next.7", | ||
"author": "Microsoft Corporation", | ||
@@ -20,3 +20,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"lsif-protocol": "0.6.0-next.5", | ||
"lsif-protocol": "0.6.0-next.6", | ||
"uuid": "^8.3.2", | ||
@@ -23,0 +23,0 @@ "vscode-uri": "^3.0.2", |
Sorry, the diff of this file is not supported yet
220681
784
+ Addedlsif-protocol@0.6.0-next.6(transitive)
- Removedlsif-protocol@0.6.0-next.5(transitive)
Updatedlsif-protocol@0.6.0-next.6