Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const projectInvite = await super.create(ctx);
let token = await ProjectInvite.generateInviteToken(
projectInvite.id, project.name, project.id
);
token = token.replace(/\./g, '~');
const context = {
url: url.resolve(config.FRONTEND_URL, `/accept-invite/${token}`),
projectName: project.name,
name
};
const mailOptions = {
from: config.MAIL_FROM,
to: email,
subject: 'You have been invited to join a project',
text: ejs.render(projectInviteTXT, context),
html: ejs.render(projectInviteHTML, context)
};
this.options.mail.sendMail(mailOptions)
.then(info => {
console.log('Message sent: %s', info.messageId); // tslint:disable-line
})
.catch(err => {
console.error(err);
});
return projectInvite;
}
.forEach(function (file) {
compilation.assets[file] = new webpack_sources_1.ConcatSource(ejs.render(_this.options.bannerTemplate, {
filename: outputPath,
licenseInfo: renderedFile.replace(/\*\//g, '') // remove premature comment endings
}), '\n', compilation.assets[file]);
});
}
if (!whetherContinue) {
throw new Error('项目不存在模板文件,终止创建');
}
} else {
templateData.blocks = material.getBlockComponentsPaths({
cwd,
name,
blocks,
preview,
});
logger.info('templateData', templateData);
for (let file of scaffoldTemplate.page) {
let templateContent = fs.readFileSync(file);
templateContent = templateContent.toString();
const outputTemplateContent = await ejs.render(templateContent, templateData, { async: true });
let basename = path.basename(file).replace('.ejs', '');
basename = material.parseFilename(basename, templateData);
const pageOutput = './pages/' + pageFolderName;
const clientFolder = getClientFolderName(nodeFramework);
const outputFilePath = path.join(cwd, clientFolder, pageOutput, basename);
logger.info('outputFilePath', outputFilePath);
await write(outputFilePath, outputTemplateContent);
pageResult.appendFiles(outputFilePath);
pageResult.setOutput('page', pageOutput);
}
}
return pageResult;
dashboard.on('checkEdit', function(type, check, partial) {
if (type !== 'http' && type !== 'https') return;
partial.push(ejs.render(template, { locals: { check: check } }));
});
const createAWSNodeJSFuncFile = (serverless, handlerPath) => {
const handlerInfo = path.parse(handlerPath);
const handlerDir = path.join(serverless.config.servicePath, handlerInfo.dir);
const handlerFile = `${handlerInfo.name}.js`;
const handlerFunction = handlerInfo.ext.replace(/^\./, '');
let templateFile = path.join(__dirname, functionTemplateFile);
if (serverless.service.custom &&
serverless.service.custom['serverless-jest-plugin'] &&
serverless.service.custom['serverless-jest-plugin'].functionTemplate) {
templateFile = path.join(serverless.config.servicePath,
serverless.service.custom['serverless-jest-plugin'].functionTemplate);
}
const templateText = fse.readFileSync(templateFile).toString();
const jsFile = ejs.render(templateText, {
handlerFunction,
});
const filePath = path.join(handlerDir, handlerFile);
serverless.utils.writeFileDir(filePath);
if (serverless.utils.fileExistsSync(filePath)) {
const errorMessage = [
`File "${filePath}" already exists. Cannot create function.`,
].join('');
throw new serverless.classes.Error(errorMessage);
}
fse.writeFileSync(path.join(handlerDir, handlerFile), jsFile);
const functionDir =
handlerDir
renderSync: function(text, metadata) {
return ejs.render(text, metadata);
},
render: function(text, metadata, done) {
function generatePackage(packageDefinition) {
return ejs.render(PACKAGE_TEMPLATE, {packageDefinition: packageDefinition});
}
fs.readFile(resourcePath, 'utf8', (err, data) => {
if(err) onError('Error reading the file "'+file+'"', err, reject);
try {
global[utils.GLOBAL_CURRENT_EJS_FILE_CONTEXT] = {
absoluteStuffPath,
cacheStuffFolderPath,
destinyPath
};
const component = ejs.render(data, {
...vars,
"name": stuffName,
...patterns.list
}, {delimiter: delimiter});
const p = destinyPath.replace(new RegExp(EJS_EXTENSION+'$'), '');
fs.writeFile(p, component);
resolve();
}catch(err){
onError('Opss!', err, reject);
}
});
});
function renderEJS (TEMPLATE, data) {
return EJS.render(fs.readFileSync(TEMPLATE, { encoding: 'utf-8' }), data, { delimiter: '%' })
}