async persistSources(sourceContainer, packageVersions) { const sources = sourceContainer.outputSources(); await Promise.all(sources.map((file) => fs.outputFile(path.join(this.appPath, file.fileName), file.content))); const packageJson = fs.readJsonSync(path.join(this.appPath, 'package.json')); packageJson.cubejsTemplates = { ...packageJson.cubejsTemplates, ...packageVersions, }; await fs.writeJson(path.join(this.appPath, 'package.json'), packageJson, { spaces: 2, }); }
async downloadPackages() { await this.downloadRepo(); await decompress(this.repoArchivePath, this.tmpFolderPath, { plugins: [decompressTargz()], }); const dir = fs.readdirSync(this.tmpFolderPath).find((name) => !name.endsWith('tar.gz')); await executeCommand('npm', ['install'], { cwd: path.resolve(this.tmpFolderPath, dir) }); return { packagesPath: path.join(this.tmpFolderPath, dir, 'packages'), }; }
function copyPublicFolder() { fs.copySync(paths.appPublic, paths.appBuild, { dereference: true, filter: file => file !== paths.appHtml, }); }
/** * @public * @description This function starts service * @example * gladys.services['rtsp-camera'].start(); */ async function start() { logger.log('starting RTSP service'); // make sure the tempFolder exists await fse.ensureDir(gladys.config.tempFolder); }
main().catch((error) => { console.error(error); process.exit(1); }).then(() => { return fs.remove(tempDir); });
function cleanJS() { for (const filename of jsPaths) { const content = fs.readFileSync(filename, "utf8") process.once("exit", () => fs.outputFileSync(filename, content)) fs.outputFileSync(filename, minifyJS(content)) } }
function setupNode() { const basePath = path.resolve(nodePath, isWin ? "" : "..") return trash(basePath) .then(() => fs.ensureLink(process.execPath, nodePath)) }
fileHash(file) { return new Promise((resolve, reject) => { const hash = crypto.createHash('sha1'); const stream = fs.createReadStream(file); stream.on('error', err => reject(err)); stream.on('data', chunk => hash.update(chunk)); stream.on('end', () => resolve(hash.digest('hex'))); }); }
const rmDirFiles = dir => { const dirPath = fs.readdirSync(dir); dirPath.map(item => { const currentPath = path.join(dir, item); console.log(`rmove ${currentPath}`); fileTool.removeSync(currentPath); }); }
fs.readFileSync(gitignorePath, "utf8") .split(/\r?\n/) .map((sourceLine) => { sourceLine = sourceLine.trim() if (sourceLine !== "") { return sourceLine.startsWith("/") ? sourceLine.slice(1) : "**/" + sourceLine } return sourceLine }) .filter(Boolean)
function copyBundle() { const srcPath = path.resolve(buildPath, "esm.js") return fs.existsSync(srcPath) ? fs.copy(srcPath, loaderPath) : Promise.resolve() }
const copyPublicFolder = () => { fs.copySync(paths.appPublic, paths.appBuild, { dereference: true, filter: file => file !== paths.appHtml, }); }
function copyPublicFolder() { fs.copySync(paths.appPublic, paths.appBuild, { dereference: true, filter: file => file !== paths.appHtml, }); }
function cleanJS() { for (const filename of jsPaths) { const content = fs.readFileSync(filename, "utf8") process.once("exit", () => fs.outputFileSync(filename, content)) fs.outputFileSync(filename, minifyJS(content)) } }