ts-pkg-installer
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -300,24 +300,32 @@ // ts-pkg-installer.ts | ||
} | ||
// By default, we look for reference paths explicitly stated, but can switch to "dts-bundle" mode. | ||
var referencePathRegex = TypeScriptPackageInstaller.referencePathRegex; | ||
var reducer = function (wrapped, line) { | ||
if (state === DeclarationFileState.Header) { | ||
// See if we have a reference path (which is a form of comment). | ||
var referencePathMatches = line.match(TypeScriptPackageInstaller.referencePathRegex); | ||
var isReferencePath = referencePathMatches && true; | ||
if (isReferencePath) { | ||
// Rewrite the reference path relative to the destination typings directory. | ||
var referencePath = referencePathMatches[1]; | ||
assert(referencePath); | ||
line = _this.rewriteReferencePath(referencePath, referencePathDir); | ||
// See if we have one of the dts-bundle header lines, and switch to looking for those comments if we do. | ||
if (_this.isDtsBundleHeader(line)) { | ||
referencePathRegex = TypeScriptPackageInstaller.dtsBundleReferencePathRegex; | ||
} | ||
else { | ||
// See if we have a comment or blank line. | ||
var isComment = line.match(commentRegex) && true; | ||
var isBlank = !isComment && line.match(blankRegex) && true; | ||
// Stay in header state if we have a comment or blank line. | ||
if (!(isComment || isBlank)) { | ||
// Transitioning out of header state, so emit the module declaration. | ||
if (!(_this.config.noWrap)) { | ||
wrapped.push(_this.moduleDeclaration()); | ||
// See if we have a reference path (which is a form of comment). | ||
var referencePathMatches = line.match(referencePathRegex); | ||
var isReferencePath = referencePathMatches && true; | ||
if (isReferencePath) { | ||
// Rewrite the reference path relative to the destination typings directory. | ||
var referencePath = referencePathMatches[1]; | ||
assert(referencePath); | ||
line = _this.rewriteReferencePath(referencePath, referencePathDir); | ||
} | ||
else { | ||
// See if we have a comment or blank line. | ||
var isComment = line.match(commentRegex) && true; | ||
var isBlank = !isComment && line.match(blankRegex) && true; | ||
// Stay in header state if we have a comment or blank line. | ||
if (!(isComment || isBlank)) { | ||
// Transitioning out of header state, so emit the module declaration. | ||
if (!(_this.config.noWrap)) { | ||
wrapped.push(_this.moduleDeclaration()); | ||
} | ||
state = DeclarationFileState.Body; | ||
} | ||
state = DeclarationFileState.Body; | ||
} | ||
@@ -356,2 +364,8 @@ } | ||
}; | ||
// Check if the line looks like one of the header lines that dts-bundle generates. | ||
TypeScriptPackageInstaller.prototype.isDtsBundleHeader = function (line) { | ||
return (line.match(TypeScriptPackageInstaller.dtsBundleHeader1Regex) || | ||
line.match(TypeScriptPackageInstaller.dtsBundleHeader2Regex)) | ||
&& true; | ||
}; | ||
// Rewrite the secondary declaration file whose contents are provided. | ||
@@ -578,2 +592,6 @@ // - *contents*: Contents of the secondary declaration file (TypeScript *.d.ts file) | ||
TypeScriptPackageInstaller.referencePathRegex = /^ *\/\/\/ *<reference *path *= *['"](.*)["'] *\/> *$/; | ||
// Recognize the parts of a declaration generated by dts-bundle. | ||
TypeScriptPackageInstaller.dtsBundleHeader1Regex = /^\/\/ Generated by dts-bundle .*/; | ||
TypeScriptPackageInstaller.dtsBundleHeader2Regex = /^\/\/ Dependencies for this module:.*/; | ||
TypeScriptPackageInstaller.dtsBundleReferencePathRegex = /\/\/ +(.*)/; | ||
return TypeScriptPackageInstaller; | ||
@@ -580,0 +598,0 @@ })(); |
@@ -167,2 +167,7 @@ // ts-pkg-installer.ts | ||
// Recognize the parts of a declaration generated by dts-bundle. | ||
private static dtsBundleHeader1Regex = /^\/\/ Generated by dts-bundle .*/; | ||
private static dtsBundleHeader2Regex = /^\/\/ Dependencies for this module:.*/; | ||
private static dtsBundleReferencePathRegex = /\/\/ +(.*)/; | ||
private options: Options; | ||
@@ -397,27 +402,36 @@ private config: Config; | ||
// By default, we look for reference paths explicitly stated, but can switch to "dts-bundle" mode. | ||
var referencePathRegex = TypeScriptPackageInstaller.referencePathRegex; | ||
var reducer = (wrapped: string[], line: string): string[] => { | ||
if (state === DeclarationFileState.Header) { | ||
// See if we have a reference path (which is a form of comment). | ||
var referencePathMatches: string[] = line.match(TypeScriptPackageInstaller.referencePathRegex); | ||
var isReferencePath: boolean = referencePathMatches && true; | ||
if (isReferencePath) { | ||
// See if we have one of the dts-bundle header lines, and switch to looking for those comments if we do. | ||
if (this.isDtsBundleHeader(line)) { | ||
referencePathRegex = TypeScriptPackageInstaller.dtsBundleReferencePathRegex; | ||
// Rewrite the reference path relative to the destination typings directory. | ||
var referencePath: string = referencePathMatches[1]; | ||
assert(referencePath); | ||
line = this.rewriteReferencePath(referencePath, referencePathDir); | ||
} else { | ||
// See if we have a comment or blank line. | ||
var isComment: boolean = line.match(commentRegex) && true; | ||
var isBlank: boolean = !isComment && line.match(blankRegex) && true; | ||
// See if we have a reference path (which is a form of comment). | ||
var referencePathMatches: string[] = line.match(referencePathRegex); | ||
var isReferencePath: boolean = referencePathMatches && true; | ||
if (isReferencePath) { | ||
// Stay in header state if we have a comment or blank line. | ||
if (! (isComment || isBlank)) { | ||
// Transitioning out of header state, so emit the module declaration. | ||
if (!(this.config.noWrap)) { | ||
wrapped.push(this.moduleDeclaration()); | ||
// Rewrite the reference path relative to the destination typings directory. | ||
var referencePath: string = referencePathMatches[1]; | ||
assert(referencePath); | ||
line = this.rewriteReferencePath(referencePath, referencePathDir); | ||
} else { | ||
// See if we have a comment or blank line. | ||
var isComment: boolean = line.match(commentRegex) && true; | ||
var isBlank: boolean = !isComment && line.match(blankRegex) && true; | ||
// Stay in header state if we have a comment or blank line. | ||
if (! (isComment || isBlank)) { | ||
// Transitioning out of header state, so emit the module declaration. | ||
if (!(this.config.noWrap)) { | ||
wrapped.push(this.moduleDeclaration()); | ||
} | ||
state = DeclarationFileState.Body; | ||
} | ||
state = DeclarationFileState.Body; | ||
} | ||
@@ -463,2 +477,9 @@ } | ||
// Check if the line looks like one of the header lines that dts-bundle generates. | ||
private isDtsBundleHeader(line: string): boolean { | ||
return (line.match(TypeScriptPackageInstaller.dtsBundleHeader1Regex) || | ||
line.match(TypeScriptPackageInstaller.dtsBundleHeader2Regex)) | ||
&& true; | ||
} | ||
// Rewrite the secondary declaration file whose contents are provided. | ||
@@ -465,0 +486,0 @@ // - *contents*: Contents of the secondary declaration file (TypeScript *.d.ts file) |
{ | ||
"name": "ts-pkg-installer", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "TypeScript package installer", | ||
@@ -5,0 +5,0 @@ "main": "bin/ts-pkg-installer.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
105963
22
1575