Comparing version 1.3.5 to 1.4.0
@@ -0,0 +0,0 @@ // jshint esversion: 6 |
@@ -0,0 +0,0 @@ // jshint esversion: 6 |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ // jshint esversion: 6 |
44
index.js
@@ -22,3 +22,3 @@ #!/usr/bin/env node | ||
name: "Plexiform", | ||
version: "1.3.5", | ||
version: "1.4.0", | ||
author: "Raith" | ||
@@ -33,3 +33,2 @@ }; | ||
const fs = require('fs-extra'); | ||
const md = require('./includes/markdown-config-loader'); | ||
@@ -61,4 +60,18 @@ var base_utils = require("./includes/base-utils.js").utils; | ||
var config_name = argv.options.config || argv.options.c || null; | ||
var config_processor = argv.options.processor || argv.options.p || null; | ||
var output_folder = argv.options.output || argv.options.o || null; | ||
if ("debug" in argv.options) { | ||
console.log("DEBUG INFO:\n"); | ||
console.log(`build_name = ${build_name}`); | ||
if (build_name) console.log(` resolved = ${require.resolve(build_name)}`); | ||
console.log(`config_name = ${config_name}`); | ||
if (config_name) console.log(` resolved = ${require.resolve(config_name)}`); | ||
console.log(`config_processor = ${config_processor}`); | ||
if (config_processor) console.log(` resolved = ${require.resolve(config_processor)}`); | ||
console.log(`output_folder = ${output_folder}`); | ||
console.log("Module paths:", module.paths); | ||
console.log("Require paths:", require.paths); | ||
} | ||
if (argv.command && !(argv.command in recognisedCommands)) { | ||
@@ -77,3 +90,3 @@ console.log(`ERROR! Unrecognised command ${argv.command}`); | ||
plexiform build | ||
plexiform build --build|-b <build_name> [--config|-c <config_name>] [--output|-o <output_folder>] | ||
plexiform build --build|-b <build_name> [--config|-c <config_name>] [--process|-p <config_processor>] [--output|-o <output_folder>] | ||
@@ -94,2 +107,7 @@ "plexiform init" | ||
<config_processor> | ||
This should refer to a file with extension ".js" in the CWD or modules path (for require). | ||
It is a node module which exports a single method named "process" with signature (raw_file_content): config_object which will process your config file as necessary. | ||
NOTE: The config_processor must *always* be specified, and is *only* invoked, if the config_name extension is anything other than ".js" or ".json". | ||
<output_folder> | ||
@@ -118,3 +136,3 @@ The folder into which files are generated. | ||
if (!fs.existsSync(plexiformconfigname) || opt_force_overwrite) { | ||
let configcontent = '{\n\t"build_name": "./path/to/build_module.js",\n\t"config_name": "./path/to/config_file.json",\n\t"output_folder": "./path/to/output_folder/"\n}\n'; | ||
let configcontent = '{\n\t"build_name": "./path/to/build_module.js",\n\t"config_name": "./path/to/config_file.json",\n\t"config_processor": null,\n\t"output_folder": "./path/to/output_folder/"\n}\n'; | ||
fs.outputFileSync(plexiformconfigname, configcontent); | ||
@@ -131,3 +149,3 @@ } else { | ||
pconfig = require(plexiformconfigname); | ||
({ build_name, config_name, output_folder } = pconfig); | ||
({ build_name, config_name, config_processor, output_folder } = pconfig); | ||
console.log("Loaded"); | ||
@@ -155,7 +173,15 @@ } catch (e) { | ||
try { | ||
if (config_name.match(/\.md$/)) { | ||
var mdconfig = fs.readFileSync(config_name).toString(); | ||
config = md.buildConfig(md.parse(mdconfig)); | ||
if (config_name.match(/\.(json|js)$/)) { | ||
config = require(config_name); | ||
} else { | ||
config = require(config_name); | ||
var rawconfig = fs.readFileSync(config_name).toString(); | ||
try { | ||
var processor = require(config_processor).process; | ||
config = processor(rawconfig); | ||
console.log(`Processed config using "${config_processor}"`); | ||
} catch (e2) { | ||
console.log(`ERROR! Not able to process config using "${config_processor}"`); | ||
} | ||
} | ||
@@ -162,0 +188,0 @@ } catch (e) { |
{ | ||
"name": "plexiform", | ||
"version": "1.3.5", | ||
"version": "1.4.0", | ||
"description": "A very simple template-driven generator.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# Plexiform | ||
> **v1.3.5** | ||
> **v1.4.0** | ||
@@ -65,1 +65,2 @@ | In this document | | ||
| 2017-09-15 | v1.3.5 | Raith | Added support for MarkDown config :) | | ||
| 2017-09-17 | v1.4.0 | Raith | Added support for build config processor | |
@@ -0,0 +0,0 @@ { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66
20902
11
323
9