New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

seng-generator

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seng-generator - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

2

package.json
{
"name": "seng-generator",
"version": "0.3.0",
"version": "0.4.0",
"description": "A CLI generator to create code based on templates",

@@ -5,0 +5,0 @@ "preferGlobal": true,

@@ -32,3 +32,4 @@ # seng generator

You can create as many templates as you need. It's also possible to create multiple template folders.
You can create as many templates as you need. It's also possible to create multiple template folders (a comma
separated templatePath can be used if there are multiple folders with templates).
You can for example create a template folder per project so it can be shared with other project members together with the rest of the code.

@@ -35,0 +36,0 @@

@@ -14,21 +14,23 @@ const path = require('path');

module.exports = function generate(type, options, settings) {
const paths = settings.templatePath.split(',');
if (!pathExists(settings.templatePath)) {
templatePath = paths.find((templatePath) => pathExists(path.join(templatePath, '/' + type)));
if(!templatePath) {
console.log();
console.error(chalk.red(`Template folder (${path.resolve(settings.templatePath)}) doesn't exist`));
console.error(chalk.red(`Template folder that contains template ${type} doesn't exist`));
return;
}
const fullTemplatePath = path.join(settings.templatePath, '/' + type);
if (!pathExists(fullTemplatePath)) {
if (!pathExists(templatePath)) {
console.log();
console.log(chalk.red(`'${options.type}' template folder doesn't exist in ${path.resolve(settings.templatePath)}`));
console.error(chalk.red(`Template folder (${path.resolve(settings.templatePath)}) doesn't exist`));
return;
}
const fullTemplatePath = path.join(templatePath, '/' + type);
console.log();
console.log(chalk.green(chalk.bold(`Generating files from '${type}' template with name: ${options.name}`)));
metalsmith(fullTemplatePath)

@@ -35,0 +37,0 @@ .metadata(Object.assign({}, getNames(options.name)))

@@ -41,6 +41,2 @@ const settingsFile = '.senggenerator';

exports.setTemplateSettings = function (settings) {
//fs.writeFileSync(path.resolve(settingsFile), JSON.stringify(settings, null, 2));
};
exports.hasLocalSettings = function (settingsPath = '.') {

@@ -96,12 +92,16 @@ return fs.existsSync(path.join(settingsPath, settingsFile));

exports.getTemplateSettings = function (templatePath) {
const dirContents = fs.readdirSync(templatePath);
const paths = templatePath.split(',');
let result = {};
dirContents.forEach((content) => {
const contentPath = path.join(templatePath, content);
paths.forEach((templatePath) => {
const dirContents = fs.readdirSync(templatePath);
if (fs.statSync(contentPath).isDirectory()) {
result[content] = this.getLocalSettings(contentPath);
}
dirContents.forEach((content) => {
const contentPath = path.join(templatePath, content);
if (fs.statSync(contentPath).isDirectory()) {
result[content] = this.getLocalSettings(contentPath);
}
});
});

@@ -108,0 +108,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc