Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @ts-check
const path = require('path')
const fs = require('fs')
const JoyCon = require('joycon').default
const joycon = new JoyCon({
stopDir: path.dirname(process.cwd())
})
joycon.addLoader({
test: /\.ya?ml$/,
loadSync: filepath =>
require('./yaml.min').safeLoad(fs.readFileSync(filepath, 'utf8'))
})
joycon.addLoader({
test: /\.toml$/,
loadSync: filepath =>
require('./toml.min').parse(fs.readFileSync(filepath, 'utf8'))
})
module.exports = {
function loadSvgoConfig(cwd) {
const joycon = new JoyCon()
const readFile = promisify(fs.readFile)
joycon.addLoader({
test: /\.yml$/,
async load(filepath) {
const content = await readFile(filepath, 'utf8')
return require('js-yaml').safeLoad(content)
}
})
return joycon
.load(
['.svgo.yml', '.svgo.js', '.svgo.json'],
cwd,
path.dirname(process.cwd())
module.exports = cwd => {
const configLoader = new JoyCon({ cwd, stopDir: path.dirname(process.cwd()) })
configLoader.addLoader(rcLoader)
configLoader.addLoader(tsLoader)
return {
load(opts, noCache) {
if (noCache) {
configLoader.clearCache()
}
return configLoader.loadSync(opts)
},
resolve(opts, noCache) {
if (noCache) {
configLoader.clearCache()
}
return configLoader.resolveSync(opts)
const path = require('path')
const JoyCon = require('joycon').default
const joycon = new JoyCon({
files: ['saofile.js', 'saofile.json']
})
module.exports = cwd =>
joycon.load({
cwd,
stopDir: path.dirname(cwd)
})
module.exports.hasConfig = cwd => {
return joycon.resolve({
cwd,
stopDir: path.dirname(cwd)
})
}
const path = require('upath')
const fs = require('fs-extra')
const JoyCon = require('joycon').default
const config = new JoyCon({
stopDir: path.dirname(process.cwd())
})
config.addLoader({
test: /\.yml$/,
loadSync(filepath) {
const yaml = require('js-yaml')
const content = fs.readFileSync(filepath, 'utf8')
return yaml.load(content)
},
async load(filepath) {
const yaml = require('js-yaml')
const content = await fs.readFile(filepath, 'utf8')
return yaml.load(content)
}
})