Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export = (cwd: string): TakeoffFileData => {
const loadTakeoffFile = new JoyCon({
// Stop reading at parent dir
// i.e. Only read file from process.cwd()
cwd,
stopDir: dirname(process.cwd()),
});
const { path: filepath, data } = loadTakeoffFile.loadSync(['takeoff.md']);
if (!filepath) {
return null;
}
return { filepath, tasks: parseMarkdown(data) };
};
import cac from 'cac'
import JoyCon from 'joycon'
import fs from 'fs-extra'
import { BabelParserPlugins } from '@vuese/parser'
import Log from 'log-horizon'
import preview from './preview'
import genDocute from './genDocute'
import genMarkdown from './genMarkdown'
import server from './server'
// Gotta fix after https://github.com/tabrindle/envinfo/pull/105 gets merged (type-definitions)
const envinfo = require('envinfo')
const logger = Log.create()
const cli = cac()
const joycon = new JoyCon({
packageKey: 'vuese'
})
joycon.addLoader({
test: /\.vueserc$/,
async load(filePath) {
const source = await fs.readFile(filePath, 'utf-8')
return JSON.parse(source)
}
})
export type CliOptions = {
include: string | string[]
exclude: string | string[]
outDir: string
markdownDir: string
markdownFile: string
// @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 = {
import path from 'path'
import fs from 'fs'
import JoyCon from 'joycon'
import requireFromString from 'require-from-string'
const configLoader = new JoyCon({
stopDir: path.dirname(process.cwd())
})
configLoader.addLoader({
test: /\.[jt]s$/,
loadSync(id) {
const content = require('@babel/core').transform(
fs.readFileSync(id, 'utf8'),
{
babelrc: false,
configFile: false,
filename: id,
presets: [
[
require('@babel/preset-env'),
{
this.bin = bin || (process.argv[1] ? path.basename(process.argv[1]) : 'cli')
this.commands = []
this.options = new Options()
this.extraHelps = []
if (typeof defaultOpts === 'boolean') {
this.helpOpt = defaultOpts
this.versionOpt = defaultOpts
} else if (typeof defaultOpts === 'object') {
this.helpOpt = defaultOpts.help !== false
this.versionOpt = defaultOpts.version !== false
}
this.pkg = Object.assign(
{},
pkg || new JoyCon({ files: ['package.json'], cwd: parentDir }).loadSync().data
)
if (this.versionOpt) {
this.option('version', {
desc: 'Display version',
alias: 'v',
type: 'boolean'
})
}
if (this.helpOpt) {
this.option('help', {
desc: `Display help (You're already here)`,
alias: 'h',
type: 'boolean'
})
}
constructor(options: InputOptions) {
super()
if (options.config !== false) {
const joycon = new JoyCon({
files: [
typeof options.config === 'string'
? options.config
: 'vue-compile.config.js'
],
stopDir: path.dirname(process.cwd())
})
const { data: config, path: configPath } = joycon.loadSync()
if (configPath) {
debug(`Using config file: ${configPath}`)
}
options = { ...options, ...config}
}
import { dirname } from 'path';
import { readFileSync } from 'fs';
import JoyCon from 'joycon';
const requireFromString = require('require-from-string');
const configLoader = new JoyCon({
stopDir: dirname(process.cwd())
});
configLoader.addLoader({
test: /\.[jt]s$/,
loadSync(id) {
const content = require('@babel/core').transform(readFileSync(id, 'utf8'), {
babelrc: false,
configFile: false,
filename: id,
presets: [
[
require('@babel/preset-env'),
{
targets: {
node: 'current'
function loadRcFile(cwd: string): TakeoffRcFile {
const loadTakeoffRc = new JoyCon({
cwd,
});
let properties: Map = new Map();
const { path: filepath, data } = loadTakeoffRc.loadSync(['.takeoffrc', '.takeoffrc.json']);
if (!filepath) {
return { exists: false, properties, rcRoot: '' };
}
if (filepath && typeof data === 'string' && data.charAt(0) === '{') {
try {
const result = JSON.parse(data);
Object.keys(result).forEach((key: string) => properties.set(key, result[key]));
} catch (e) {
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)