new Router() .get('/alive', (ctx, next) => { ctx.body = { message: 'server alive', time: new Date(), }; ctx.status = 200; }) .use('/api/v1', apiRoutes.routes(), apiRoutes.allowedMethods()) .get('*.*', statics(configs.staticPath)) .get('/*', (ctx, next) => { ctx.type = 'html'; ctx.body = fs.createReadStream(path.join(configs.staticPath, '/index.html')); next(); })
listPlatforms(projectDir) { const platforms = require('../platform/platforms') const platformsDir = path.join(projectDir, 'platforms') if (!fse.existsSync(platformsDir)) { return [] } const subdirs = fse.readdirSync(platformsDir) return subdirs.filter(function(p) { return Object.keys(platforms).indexOf(p) > -1 }) }
require('../factory')({ bootstrapLocation: join(__dirname, '../node_modules/@openui5/sap.ui.core/src/sap-ui-core.js') }).then(({ sap }) => { require('./odata-client')({ sap, assert }) }, reason => { console.error(reason) assert(() => !'invalid boostrap') })
const renderPage = function (req, res) { const history = createHistory( ); const store = createStore(history); assets.manifest.text = fs.readFileSync(join(__dirname, assets.manifest.js), 'utf-8'); renderApp(req.url, res, store, assets); }
async installForIOS(plugins) { if (!Array.isArray(plugins) || plugins.length <= 0) { return } plugins.forEach(plugin => { const buildPatch = podfile.makeBuildPatch(plugin.name, plugin.version) // Build Podfile config. podfile.applyPatch(path.join(this.config.iosPath, 'Podfile'), buildPatch) this.emit(LOGLEVEL.SUCCESS, `${plugin.name} has installed success in iOS project`) }) }
export function getModulesInfo(toolbox: IToolbox): any { const config = toolbox.parameters.options.__config let info = {} if (config) { const moduleConfigFilePath = path.join(config.moduleRoot, config.moduleConfigFileName) info = jetpack.read(moduleConfigFilePath, 'json') } return info }
test('getAbsolutePath', () => { const relativePath = './test' const absolutePath = '/User/username' expect(fs.getAbsolutePath(relativePath)).toBe(path.join(`${process.cwd()}`, relativePath)) expect(fs.getAbsolutePath(absolutePath)).toBe(absolutePath) })
const loadModulePath = (moduleName: string, extra?: any) => { try { const localPath = require.resolve(path.join(__dirname, '../node_modules', moduleName, extra || '')) return localPath.slice(0, localPath.lastIndexOf(moduleName) + moduleName.length) } catch (e) { return moduleName } }
beforeAll(() => { jetpack.write(path.join(root, filename), config) })
function root (args) { args = Array.prototype.slice.call(arguments, 0) return path.join.apply(path, [ROOT].concat(args)) }
const isWeexWorkSpace = async (local) => { const isWeex = await fse.exists(path.join(local, 'platforms')) return isWeex }
fs.readdirSync(bundles) .forEach(bundle => { const bundlePath = join(bundles, bundle); // ensure path has package.json if (!fs.existsSync(join(bundlePath, 'package.json'))) return; // npm binary based on OS const npmCmd = os.platform().startsWith('win') ? 'npm.cmd' : 'npm'; // install folder cp.spawn(npmCmd, ['i'], { env: process.env, cwd: bundlePath, stdio: 'inherit' }); });
const isWeexWorkSpace = async (local) => { const isWeex = await fse.exists(path.join(local, 'platforms')) return isWeex }