async function uploadData (uploadURL, authToken, filename, opts) { // filename may either be .clinic-doctor.html or the data directory // .clinic-doctor const filePrefix = path.join(filename).replace(/\.html$/, '') const isPrivate = opts && opts.private console.log(`Uploading data for ${filePrefix} and ${filePrefix}.html`) const result = await tarAndUploadPromisified(path.resolve(filePrefix), uploadURL, authToken, { private: isPrivate }) result.url = `${uploadURL}${result.html}` return result }
(process.env.NODE_PATH || '') .split(path.delimiter) .filter(folder => folder && !path.isAbsolute(folder)) .map(folder => path.resolve(appDirectory, folder)) .join(path.delimiter)
async didLoad() { // 数据模型初始化 var modelsPath = path.resolve(__dirname, './app/model'); this.app.initExtendModel(modelsPath); }
app.beforeStart(function*() { // dumpConfig() dynamically json = readJSON(path.join(baseDir, 'run/application_config.json')); assert(json.config.dynamic === 1, 'should dump in config'); json = readJSON(path.join(baseDir, 'run/agent_config.json')); assert(json.config.dynamic === 0, 'should dump in config'); yield sleep(2000); app.config.dynamic = 2; });
beforeAll(async function(state) { const DEVTOOLS_DIR = path.dirname( require.resolve('chrome-devtools-frontend/front_end/shell.json')); const frontendFolder = await fsMkdtemp(path.join(os.tmpdir(), 'ndb-test-frontend-')); await new ReleaseBuilder([ path.join(__dirname, '..', 'front_end'), DEVTOOLS_DIR, path.join(__dirname, '..'), path.join(__dirname, '..', '..', '..') ], frontendFolder).buildApp('integration_test_runner'); state.frontendFolder = frontendFolder; });
const mkdirsSync = function(dirname) { if (fs.existsSync(dirname)) { return true; } if (mkdirsSync(path.dirname(dirname))) { fs.mkdirSync(dirname); return true; } }
function renderPost (results) { const templateStr = fs.readFileSync(path.resolve(__dirname, 'release.hbs')).toString('utf8') const template = Handlebars.compile(templateStr, { noEscape: true }) const view = Object.assign({ date: new Date().toISOString(), versionSlug: slugify(results.version) }, results) return Object.assign({ content: template(view) }, results) }
loadDatabase() { if (this.isDBReady) return; const db = new Datastore({ autoload: true, filename: path.join(config.dbPath, this.user._id, 'settings', 'feeds.db'), }); this.isDBReady = true; return db; }
pkg() { // TODO(ak239spb): implement it as decorations over package.json file. try { return require(path.join(fileURLToPath(this._info.cwd), 'package.json')); } catch (e) { return null; } }
async getFiles(dir, fileList = []) { const files = await fs.readdir(path.join(this.localPath(), dir)); // eslint-disable-next-line no-restricted-syntax for (const file of files) { const stat = await fs.stat(path.join(this.localPath(), dir, file)); if (stat.isDirectory()) { fileList = await this.getFiles(path.join(dir, file), fileList); } else fileList.push(path.join(dir, file)); } return fileList; }
// Run markdownlint the same way the corresponding repositories do tape("https://github.com/eslint/eslint", (test) => { const rootDir = "./test-repos/eslint-eslint"; const globPatterns = [ join(rootDir, "docs/**/*.md") ]; const configPath = join(rootDir, ".markdownlint.yml"); lintTestRepo(test, globPatterns, configPath); });
tape("https://github.com/mkdocs/mkdocs", (test) => { const rootDir = "./test-repos/mkdocs-mkdocs"; const globPatterns = [ join(rootDir, "README.md"), join(rootDir, "CONTRIBUTING.md"), join(rootDir, "docs/*"), "!" + join(rootDir, "docs/CNAME") ]; const configPath = join(rootDir, ".markdownlintrc"); lintTestRepo(test, globPatterns, configPath); });
loadDatabase() { if (this.ready) return; const db = new Datastore({ autoload: true, filename: path.join(config.dbPath, this.user._id, 'notifications.db'), }); this.ready = true; return db; }
async didLoad() { // 数据模型初始化 var modelsPath = path.resolve(__dirname, './app/model'); this.app.initExtendModel(modelsPath); }
(process.env.NODE_PATH || '') .split(path.delimiter) .filter(folder => folder && !path.isAbsolute(folder)) .map(folder => path.resolve(appDirectory, folder)) .join(path.delimiter)