@ikerin/build-readme
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -6,7 +6,6 @@ "use strict"; | ||
const process_1 = require("process"); | ||
const path_1 = require("path"); | ||
const readmePath = path_1.isAbsolute(process.argv[2]) ? process.argv[2] : path_1.join(process_1.cwd(), process.argv[2]); | ||
const readmePath = process.argv[2]; | ||
const url = process.argv[3]; | ||
const text = fs_1.readFileSync(readmePath, 'utf8'); | ||
const { content, replacements } = _1.buildReadme(readmePath, text, url); | ||
const { content, replacements } = _1.buildReadme(readmePath, text, process_1.cwd(), url); | ||
fs_1.writeFileSync(readmePath, content, 'utf8'); | ||
@@ -13,0 +12,0 @@ if (replacements.length) { |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
export declare const buildReadme: (readmePath: string, text: string, url?: string | undefined) => { | ||
export declare const buildReadme: (readmePath: string, text: string, dir: string, url?: string | undefined) => { | ||
content: string; | ||
@@ -11,0 +11,0 @@ replacements: { |
@@ -35,9 +35,11 @@ "use strict"; | ||
*/ | ||
const buildReadme = (readmePath, text, url) => { | ||
const buildReadme = (readmePath, text, dir, url) => { | ||
const replacements = []; | ||
const content = text.replace(matchExample, (match, name, _, section, filename, language) => { | ||
replacements.push({ name, filename }); | ||
const resolvedFilename = removeAnchorHash(url && filename.includes(url) ? filename.replace(url, path_1.dirname(readmePath)) : path_1.join(path_1.dirname(readmePath), filename)); | ||
const resolvedFilename = removeAnchorHash(url && filename.includes(url) | ||
? filename.replace(url, path_1.dirname(path_1.join(dir, readmePath))) | ||
: path_1.join(path_1.dirname(path_1.join(dir, readmePath)), filename)); | ||
if (!fs_1.existsSync(resolvedFilename)) { | ||
throw new Error(`File ${resolvedFilename} does not exist in ${path_1.dirname(readmePath)}`); | ||
throw new Error(`File ${resolvedFilename} does not exist in ${dir}`); | ||
} | ||
@@ -44,0 +46,0 @@ const content = fs_1.readFileSync(resolvedFilename, 'utf-8'); |
{ | ||
"name": "@ikerin/build-readme", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
92
0
175803