@christian-slater/util
Advanced tools
Comparing version 3.1.3 to 3.1.4
100
getConfig.js
@@ -1,5 +0,5 @@ | ||
const fs = require('fs-extra') | ||
const path = require('path') | ||
const merge = require('merge-deep') | ||
const exit = require('exit') | ||
const fs = require("fs-extra"); | ||
const path = require("path"); | ||
const merge = require("merge-deep"); | ||
const exit = require("exit"); | ||
@@ -9,13 +9,16 @@ /** | ||
*/ | ||
const abs = require('./abs.js') | ||
const fixPathSeparators = require("./fixPathSeparators.js") | ||
const logger = require('./logger.js') | ||
const log = logger('christian-slater') | ||
const abs = require("./abs.js"); | ||
const fixPathSeparators = require("./fixPathSeparators.js"); | ||
const logger = require("./logger.js"); | ||
const log = logger("christian-slater"); | ||
module.exports = function getConfig (options) { | ||
const configpath = abs(options.config || 'slater.config.js') | ||
module.exports = function getConfig(options) { | ||
const configpath = abs(options.config || "slater.config.js"); | ||
if (!fs.existsSync(configpath)) { | ||
log.error(`looks like your config file (${options.config || 'slater.config.js'}) is missing`) | ||
exit() | ||
log.error( | ||
`looks like your config file (${options.config || | ||
"slater.config.js"}) is missing` | ||
); | ||
exit(); | ||
} | ||
@@ -26,28 +29,28 @@ | ||
*/ | ||
const config = merge({ | ||
in: '/src', | ||
out:'/build', | ||
assets: { | ||
in: '/src/scripts/index.js' | ||
} | ||
}, require(configpath)) | ||
const config = merge( | ||
{ | ||
in: "./src", | ||
out: "./build", | ||
assets: { | ||
in: "./src/scripts/index.js" | ||
} | ||
}, | ||
require(configpath) | ||
); | ||
config.assets.alias = { | ||
'@': abs(path.dirname(config.assets.in)), | ||
"@": abs(path.dirname(config.assets.in)), | ||
...(config.assets.alias || {}) | ||
} | ||
}; | ||
if (!config.assets.presets) { | ||
config.assets.presets = [ | ||
'maps', | ||
'postcss' | ||
] | ||
config.assets.presets = ["maps", "postcss"]; | ||
} | ||
if (config.assets.presets && !config.assets.presets.includes('maps')) { | ||
config.assets.presets.push('maps') | ||
if (config.assets.presets && !config.assets.presets.includes("maps")) { | ||
config.assets.presets.push("maps"); | ||
} | ||
if (!config.assets.out) { | ||
config.assets.out = fixPathSeparators(path.join(config.out, 'assets')) | ||
config.assets.out = fixPathSeparators(path.join(config.out, "assets")); | ||
} | ||
@@ -58,27 +61,30 @@ | ||
*/ | ||
config.theme = {} | ||
config.theme = {}; | ||
try { | ||
config.theme = config.themes[options.theme || 'development'] | ||
config.theme = config.themes[options.theme || "development"]; | ||
} catch (e) { | ||
log.warn(`config`, `config for ${options.theme || 'development'} theme is missing`) | ||
log.warn( | ||
`config`, | ||
`config for ${options.theme || "development"} theme is missing` | ||
); | ||
} | ||
if (!config.theme) { | ||
log.error(`your ${options.theme} theme appears to be missing`) | ||
exit() | ||
log.error(`your ${options.theme} theme appears to be missing`); | ||
exit(); | ||
} | ||
config.theme.name = options.theme || 'development' | ||
config.theme.name = options.theme || "development"; | ||
config.theme.ignore = [].concat(config.theme.ignore || [], [ | ||
'**/scripts/**', | ||
'**/scripts', | ||
'**/styles/**', | ||
'**/styles', | ||
'DS_Store', | ||
'*.yml', | ||
'.DS_Store', | ||
'node_modules' | ||
]) | ||
"**/scripts/**", | ||
"**/scripts", | ||
"**/styles/**", | ||
"**/styles", | ||
"DS_Store", | ||
"*.yml", | ||
".DS_Store", | ||
"node_modules" | ||
]); | ||
@@ -88,6 +94,6 @@ /** | ||
*/ | ||
config.in = abs(config.in || '/src') | ||
config.out = abs(config.out || '/build') | ||
config.in = abs(config.in || "./src"); | ||
config.out = abs(config.out || "./build"); | ||
return config | ||
} | ||
return config; | ||
}; |
{ | ||
"name": "@christian-slater/util", | ||
"version": "3.1.3", | ||
"version": "3.1.4", | ||
"description": "shopify theme management toolkit", | ||
@@ -21,3 +21,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "ca6ae3b69d2209674952004ca72207210457d648" | ||
"gitHead": "460731c1ec4ba75759861cc6a18350f959571d76" | ||
} |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
6199
177