function Handle(electron) { global.pathEnv=path.join(electron.app.getPath("home"),"DOClever-Desktop"); if(!fs.existsSync(global.pathEnv)) { fs.mkdirSync(global.pathEnv); } this.update=new update(electron); this.plugin=new plugin(electron); this.cookie=new cookie(electron); this.member=new member(electron); this.request=require("request"); this.fs=require("fs-extra") }
constructor(repo) { this.repo = repo; this.tmpFolderPath = path.resolve('.', 'node_modules', '.tmp'); try { fs.mkdirSync(this.tmpFolderPath); } catch (err) { if (err.code === 'EEXIST') { fs.removeSync(this.tmpFolderPath); fs.mkdirSync(this.tmpFolderPath); } else { throw err; } } this.repoArchivePath = `${this.tmpFolderPath}/master.tar.gz`; }
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}`); } }
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}`); } }
inquirer.prompt(questions).then((answers) => { if (answers.overwriteDir !== undefined && !answers.overwriteDir) { console.log(chalk.red('Please try again with a different name!')); process.exit(0); } if (answers.overwriteDir === undefined) { fs.mkdirSync(`${answers.projectName}`); } process.chdir(`./${answers.projectName}`); const selectedTemplate = templates.values.find(v => v.value === answers.projectTemplate); buildFromTemplate(__dirname, process.cwd(), selectedTemplate, answers.projectName); });
async function insertLibrary (config) { const appDir = config.appdir; const targetLib = config.insertLibrary; const libraryName = path.basename(targetLib); try { fs.mkdirSync(path.join(appDir, 'Frameworks')); } catch (_) { } const outputLib = path.join(appDir, 'Frameworks', libraryName); await insertLibraryLL(outputLib, targetLib, config); }
const create = path => { const dirPath = path.substring(0, path.lastIndexOf('/')) return fs.mkdirSync(dirPath, { recursive: true }, (err) => { if (err) { throw err; } }); }
function createFolder(_path) { fs.mkdirSync(_path); }
copyAndReplace(src, dest, replacements) { if (fse.lstatSync(src).isDirectory()) { if (!fse.existsSync(dest)) { fse.mkdirSync(dest) } } else { let content = fse.readFileSync(src, 'utf8') Object.keys(replacements).forEach(regex => { content = content.replace(new RegExp(regex, 'gm'), replacements[regex]) }) fse.writeFileSync(dest, content) } }
createDir(dirname, config) { let location = this.applyPathPrefix(dirname); if (fs.existsSync(location)) { return true; } fs.mkdirSync(location); return fs.existsSync(location); }
getProjectCachePath(...addPath){ const projectConfigPath = path.join(this.projectPath, '.wordup', 'cache') if (!fs.existsSync(projectConfigPath)) { fs.mkdirSync(projectConfigPath) } if(addPath){ return path.join(projectConfigPath,...addPath) } return projectConfigPath }
function Handle(electron) { global.pathEnv=path.join(electron.app.getPath("home"),"DOClever-Desktop"); if(!fs.existsSync(global.pathEnv)) { fs.mkdirSync(global.pathEnv); } this.update=new update(electron); this.plugin=new plugin(electron); this.cookie=new cookie(electron); this.member=new member(electron); this.request=require("request"); this.fs=require("fs-extra") }
function Handle(electron) { global.pathEnv=path.join(electron.app.getPath("home"),"DOClever-Desktop"); if(!fs.existsSync(global.pathEnv)) { fs.mkdirSync(global.pathEnv); } this.update=new update(electron); this.plugin=new plugin(electron); this.cookie=new cookie(electron); this.member=new member(electron); this.request=require("request"); this.fs=require("fs-extra") }