ts-command-line-args
Advanced tools
Comparing version 2.4.1 to 2.4.2
@@ -172,6 +172,5 @@ "use strict"; | ||
copyBelowIndex = copyBelowMarker != null ? contentLines.findIndex(findLine(copyBelowMarker, snippetResult === null || snippetResult === void 0 ? void 0 : snippetResult[1])) : -1; | ||
copyAboveIndex = copyAboveMarker != null ? contentLines.findIndex(function (line) { return line.indexOf(copyAboveMarker) === 0; }) : -1; | ||
if (copyAboveIndex > -1 && copyBelowIndex > -1 && copyAboveIndex < copyBelowIndex) { | ||
throw new Error("The copyCodeAbove marker '" + options.copyCodeAbove + "' was found before the copyCodeBelow marker '" + options.copyCodeBelow + "'. The copyCodeBelow marked must be before the copyCodeAbove."); | ||
} | ||
copyAboveIndex = copyAboveMarker != null | ||
? contentLines.findIndex(function (line, index) { return line.indexOf(copyAboveMarker) === 0 && index > copyBelowIndex; }) | ||
: -1; | ||
if (snippetResult != null && copyBelowIndex < 0) { | ||
@@ -178,0 +177,0 @@ throw new Error("The copyCodeBelow marker '" + options.copyCodeBelow + "' was not found with the requested snippet: '" + snippetResult[1] + "'"); |
{ | ||
"name": "ts-command-line-args", | ||
"version": "2.4.1", | ||
"version": "2.4.2", | ||
"description": "A Typescript wrapper around command-line-args with additional support for markdown usage guide generation", | ||
@@ -5,0 +5,0 @@ "bin": { |
@@ -316,26 +316,2 @@ import { IInsertCodeOptions } from '../contracts'; | ||
it(`should should throw error if copyBelow and copyAbove are reversed`, async () => { | ||
const fileContent = [beforeInsertionLine, insertBelowToken, insertCodeAboveDefault, afterInsertionLine].join( | ||
'\n', | ||
); | ||
const fileLines = ['randomFirstLine', copyCodeAboveDefault, insertLineOne, copyCodeBelowDefault, insertLineTwo]; | ||
mockedFs.setupFunction('readFile', ((_path: string, callback: (err: Error | null, data: Buffer) => void) => { | ||
callback(null, Buffer.from(fileLines.join(EOL))); | ||
}) as any); | ||
let error: Error | undefined; | ||
try { | ||
await insertCode({ fileContent, filePath: `${sampleDirName}/'originalFilePath.ts` }, createOptions()); | ||
} catch (e) { | ||
error = e; | ||
} | ||
expect(error?.message).toEqual( | ||
`The copyCodeAbove marker '// ts-command-line-args_write-markdown_copyCodeAbove' was found before the copyCodeBelow marker '// ts-command-line-args_write-markdown_copyCodeBelow'. The copyCodeBelow marked must be before the copyCodeAbove.`, | ||
); | ||
}); | ||
it(`should should only insert file content after copyBelow token`, async () => { | ||
@@ -342,0 +318,0 @@ const fileContent = [beforeInsertionLine, insertBelowToken, insertCodeAboveDefault, afterInsertionLine].join( |
@@ -130,10 +130,6 @@ import { IInsertCodeOptions } from '../contracts'; | ||
const copyAboveIndex = | ||
copyAboveMarker != null ? contentLines.findIndex((line) => line.indexOf(copyAboveMarker) === 0) : -1; | ||
copyAboveMarker != null | ||
? contentLines.findIndex((line, index) => line.indexOf(copyAboveMarker) === 0 && index > copyBelowIndex) | ||
: -1; | ||
if (copyAboveIndex > -1 && copyBelowIndex > -1 && copyAboveIndex < copyBelowIndex) { | ||
throw new Error( | ||
`The copyCodeAbove marker '${options.copyCodeAbove}' was found before the copyCodeBelow marker '${options.copyCodeBelow}'. The copyCodeBelow marked must be before the copyCodeAbove.`, | ||
); | ||
} | ||
if (snippetResult != null && copyBelowIndex < 0) { | ||
@@ -140,0 +136,0 @@ throw new Error( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
794436
6429