writeSummary(renderer: RendererEvent) { const outputDirectory = renderer.outputDirectory; const summaryMarkdown = this.getSummaryMarkdown(renderer); try { fs.writeFileSync(`${outputDirectory}/SUMMARY.md`, summaryMarkdown); this.application.logger.write(`[typedoc-plugin-markdown] SUMMARY.md written to ${outputDirectory}`); } catch (e) { this.application.logger.write(`[typedoc-plugin-markdown] failed to write SUMMARY at ${outputDirectory}`); } }
function updateGradleConfig() { let content = fs.readFileSync(`${rnDir}/android/app/build.gradle`, 'utf8'); content = increaseGradleVersionCode(content); content = increaseGradleVersionName(content); fs.writeFileSync(`${rnDir}/android/app/build.gradle`, content); return content; }
function saveToFile(filePath, data) { fs.writeFileSync(filePath, data); }
function setReadmeContent(content) { if (!fs.existsSync(readmePath)) throw new Error(`Cannot find ${readmePath}`); return fs.writeFileSync(readmePath, content); }
function renderMdToHtml(md, targetPath, templateParams) { // Remove the header because it's going to be added back as HTML md = md.replace(/# Joplin\n/, ''); templateParams.baseUrl = 'https://joplinapp.org'; templateParams.imageBaseUrl = `${templateParams.baseUrl}/images`; templateParams.tocHtml = tocHtml(); const title = []; if (!templateParams.title) { title.push('Joplin - an open source note taking and to-do application with synchronisation capabilities'); } else { title.push(templateParams.title); title.push('Joplin'); } md = replaceGitHubByJoplinAppLinks(md); templateParams.pageTitle = title.join(' | '); const html = markdownToHtml(md, templateParams); const folderPath = dirname(targetPath); fs.mkdirpSync(folderPath); fs.writeFileSync(targetPath, html); }
writeSideBar(renderer: RendererEvent, root: string) { const childDirectory = renderer.outputDirectory.split(root + 'docs/')[1]; const docsRoot = childDirectory ? childDirectory + '/' : ''; const vuePressRoot = root + 'docs/.vuepress'; const navObject = this.getNavObject(renderer, docsRoot); const sidebarPath = vuePressRoot + '/api-sidebar.json'; const relativeNavObject = this.getNavObject(renderer); const relativeSidebarPath = vuePressRoot + '/api-sidebar-relative.json'; if (!fs.existsSync(vuePressRoot)) { fs.mkdirSync(vuePressRoot); } try { fs.writeFileSync(sidebarPath, JSON.stringify(navObject, null, 2)); fs.writeFileSync(relativeSidebarPath, JSON.stringify(relativeNavObject, null, 2)); this.application.logger.write(`[typedoc-plugin-markdown] sidebars.json updated at ${sidebarPath}`); } catch (e) { this.application.logger.write(`[typedoc-plugin-markdown] failed to update sidebars.json at ${sidebarPath}`); } }
writeSideBar(renderer: RendererEvent, docusarusRoot: string) { const childDirectory = renderer.outputDirectory.split(docusarusRoot + 'docs/')[1]; const docsRoot = childDirectory ? childDirectory + '/' : ''; const websitePath = docusarusRoot + 'website'; const packageName = renderer.project.packageInfo.name; const navObject = this.getNavObject(renderer, docsRoot); const sidebarPath = websitePath + '/sidebars.json'; let contents: any; if (!fs.existsSync(sidebarPath)) { contents = '{}'; if (!fs.existsSync(websitePath)) { fs.mkdirSync(websitePath); } } else { contents = fs.readFileSync(sidebarPath); } const jsonContent = JSON.parse(contents.toString()); const update = { ...jsonContent, [packageName]: navObject, }; try { fs.writeFileSync(sidebarPath, JSON.stringify(update, null, 2)); this.application.logger.write(`[typedoc-plugin-markdown] sidebars.json updated at ${sidebarPath}`); } catch (e) { this.application.logger.write(`[typedoc-plugin-markdown] failed to update sidebars.json at ${sidebarPath}`); } }
const jsonContent = JSON.stringify(content, null, 4); const jsContent = `module.exports = ${jsonContent}`; fs.writeFileSync(`${rootDir}/ReactNativeClient/lib/welcomeAssets.js`, jsContent, { encoding: 'utf8' });
fs.writeFileSync(filename, content)
writeSideBar(renderer: RendererEvent, docusarusRoot: string) { const childDirectory = renderer.outputDirectory.split(docusarusRoot + 'docs/')[1]; const docsRoot = childDirectory ? childDirectory + '/' : ''; const websitePath = docusarusRoot; const navObject = this.getNavObject(renderer, docsRoot); const sidebarPath = websitePath + this.sidebarName; let jsonContent: any; if (!fs.existsSync(sidebarPath)) { if (!fs.existsSync(websitePath)) { fs.mkdirSync(websitePath); } jsonContent = JSON.parse('{}'); } else { jsonContent = require(sidebarPath); } let firstKey = Object.keys(jsonContent)[0]; if (!firstKey) { firstKey = 'docs'; } jsonContent[firstKey] = Object.assign({}, jsonContent[firstKey], navObject); try { fs.writeFileSync(sidebarPath, 'module.exports = ' + JSON.stringify(jsonContent, null, 2) + ';'); this.application.logger.write(`[typedoc-plugin-markdown] ${this.sidebarName} updated at ${sidebarPath}`); } catch (e) { this.application.logger.write(`[typedoc-plugin-markdown] failed to update ${this.sidebarName} at ${sidebarPath}`); } }
write(data) { fs.ensureDirSync(path.dirname(this.filePath)); fs.writeFileSync(this.filePath, JSON.stringify(data)); }
domain: formio.config.domain ? formio.config.domain : 'https://form.io' }); fs.writeFileSync(path.join(directoryPath, 'config.js'), newConfig); done(); });
const writeTestProject = () => { fs.mkdirsSync(join(__dirname, 'test_project')) fs.mkdirsSync(join(__dirname, 'test_project', '.git')) fs.mkdirsSync(join(__dirname, 'test_project', 'node_modules')) fs.writeFileSync(join(__dirname, 'test_project', 'package.json'), JSON.stringify(PACKAGE_FILE, null, 2)) }
revokePatch(file, patch) { let content = fse.readFileSync(file, 'utf8') content = content.replace(patch.findPattern || patch.patch, '').replace(patch.findProjectPattern, '') fse.writeFileSync(file, content) }
function writeSourceMap(path, map) { const mapPath = pathUtil.join(pathUtil.dirname(path), map.file); if (path !== mapPath) { fs.writeFileSync(mapPath, JSON.stringify(map)); } else { console.warn('map file is same as source file, ignore'); // eslint-disable-line } }