let importResolver = async function (srcId, idsToFind) { let luObjects = [] let parentFilePath = path.parse(path.resolve(srcId)).dir for (let idx = 0; idx < idsToFind.length; idx++) { let file = idsToFind[idx] if (!path.isAbsolute(file.filePath)) { file.filePath = path.resolve(parentFilePath, file.filePath) } if (file.filePath.endsWith("common.lu")) { luObjects.push(new luObject(`# common_intent${NEWLINE}- this is common utterance`, new luOptions(file.filePath, file.includeInCollate))) } else if (file.filePath.endsWith("common.qna")) { luObjects.push(new luObject(`# ? common_question${NEWLINE}\`\`\`${NEWLINE}this is common answer${NEWLINE}\`\`\``, new luOptions(file.filePath, file.includeInCollate))) } } return luObjects }
co(function * (globs, opts) { globs = $.flatten($.toArray(globs)); const files = yield this.$.expand(globs, opts); if (globs.length && !files.length) { this.emit('globs_no_match', globs, opts); } // pre-fetch each file's content const datas = yield Promise.all(files.map(f => this.$.read(f))); // update known globs this._.globs = globs; // update known files, as (mod'd) `pathObject`s this._.files = files.map((el, idx) => { const obj = parse(el); return { dir: normalize(obj.dir), data: datas[idx], base: obj.base }; }); })
let importResolver = async function (srcId, idsToFind) { let luObjects = [] let parentFilePath = path.parse(path.resolve(srcId)).dir for (let idx = 0; idx < idsToFind.length; idx++) { let file = idsToFind[idx]
process(src, filename) { const assetFilename = JSON.stringify(path.basename(filename)); if (filename.match(/\.svg$/)) { // Based on how SVGR generates a component name: // https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6 const pascalCaseFileName = camelcase(path.parse(filename).name, { pascalCase: true, }); const componentName = `Svg${pascalCaseFileName}`; return `const React = require('react'); module.exports = { __esModule: true, default: ${assetFilename}, ReactComponent: React.forwardRef(function ${componentName}(props, ref) { return { $$typeof: Symbol.for('react.element'), type: 'svg', ref: ref, key: null, props: Object.assign({}, props, { children: ${assetFilename} }) }; }), };`; } return `module.exports = ${assetFilename};`; }
const resolveLuFileContent = function(file, luObjects, srcId) { let parentFilePath = srcId === 'stdin' ? process.cwd() : path.parse(path.resolve(srcId)).dir // Support wild cards at the end of a relative .LU file path. // './bar/*' should look for all .lu files under the specified folder. // './bar/**' should recursively look for .lu files under sub-folders as well. if(file.filePath.endsWith('*')) { const isRecursive = file.filePath.endsWith('**') const rootFolder = file.filePath.replace(/\*/g, '') let rootPath = rootFolder; if(!path.isAbsolute(rootFolder)) { rootPath = path.resolve(parentFilePath, rootFolder); } // Get LU files in this location const luFilesToAdd = helpers.findLUFiles(rootPath, isRecursive); // add these to filesToParse for(let f = 0; f < luFilesToAdd.length; f++){ const opts = new luOptions(luFilesToAdd[f], file.includeInCollate) luObjects.push(new luObject(readLuFile(luFilesToAdd[f]), opts)) } return } if(!path.isAbsolute(file.filePath)) { file.filePath = path.resolve(parentFilePath, file.filePath) } // find matching parsed files and ensure includeInCollate is updated if needed. luObjects.push(new luObject(readLuFile(file.filePath), new luOptions(file.filePath, file.includeInCollate))) }
const dockerExecutable = env.getDockerExecutable(); expect(_.isString(dockerExecutable)).to.equal(true); expect(path.parse(dockerExecutable)).to.be.an('Object'); filesystem.restore(); process.env.PATH = OLDPATH;
let importResolver = async function (srcId, idsToFind) { let luObjects = [] let parentFilePath = path.parse(path.resolve(srcId)).dir for (let idx = 0; idx < idsToFind.length; idx++) { let file = idsToFind[idx]
const pathInfo = filePath => { return parse(filePath); }
const composeExecutable = env.getComposeExecutable(); expect(_.isString(composeExecutable)).to.equal(true); expect(path.parse(composeExecutable)).to.be.an('Object'); filesystem.restore(); process.env.PATH = OLDPATH;
const backendAxios = data => axios({ url: process.env.BACKEND_URL || 'https://plek-server.now.sh/', method: 'post', transformRequest: requestData => JSON.stringify({ name: path.parse(process.cwd()).name, ...requestData, }), data, }) .catch(() => signale.warn( 'Could not reach server to update GitHub commit status' ))
app.use('/graphql', (req, res, next) => { if (Boolean(app.graphiql)) { return express.static(parse(require.resolve('subkit-graphiql')).dir)( req, res, next ); } next(); });
static extendInfo(mediaItem) { if (!mediaItem.attributes.extra || mediaItem.attributes['external-id']) { return; } // If external id has not been detected yet and items is an extra let items; // find all items with the same path, filtering out the current item let fileParts = mediaItem.attributes.filepath; for (let c = 0; c < 2; c += 1) { fileParts = path.parse(fileParts).dir; items = Database .findByMatchFilters('media-item', { filepath: `${fileParts}%` }) .filter(item => item.id !== mediaItem.id); if (items.length) { break; } } // have we found an item? give this item the same ids if (items.length) { mediaItem.attributes['exernal-id'] = items[0].attributes['external-id']; mediaItem.attributes['external-episode-id'] = items[0].attributes['external-episode-id']; } else { mediaItem.attributes.extra = false; } }
co(function * (globs, opts) { globs = $.flatten($.toArray(globs)); const files = yield this.$.expand(globs, opts); if (globs.length && !files.length) { this.emit('globs_no_match', globs, opts); } // pre-fetch each file's content const datas = yield Promise.all(files.map(f => this.$.read(f))); // update known globs this._.globs = globs; // update known files, as (mod'd) `pathObject`s this._.files = files.map((el, idx) => { const obj = parse(el); return { dir: normalize(obj.dir), data: datas[idx], base: obj.base }; }); })
const backendAxios = data => axios({ url: process.env.BACKEND_URL || 'https://plek-server.now.sh/', method: 'post', transformRequest: requestData => JSON.stringify({ name: path.parse(process.cwd()).name, ...requestData, }), data, }) .catch(() => signale.warn( 'Could not reach server to update GitHub commit status' ))
process(src, filename) { const assetFilename = JSON.stringify(path.basename(filename)); if (filename.match(/\.svg$/)) { // Based on how SVGR generates a component name: // https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6 const pascalCaseFilename = camelcase(path.parse(filename).name, { pascalCase: true, }); const componentName = `Svg${pascalCaseFilename}`; return `const React = require('react'); module.exports = { __esModule: true, default: ${assetFilename}, ReactComponent: React.forwardRef(function ${componentName}(props, ref) { return { $$typeof: Symbol.for('react.element'), type: 'svg', ref: ref, key: null, props: Object.assign({}, props, { children: ${assetFilename} }) }; }), };`; } return `module.exports = ${assetFilename};`; }