Sha256: 73335abdb86830fc2c6f74c68f477ecb7757835bc7432b3911b0c8e739552066
Contents?: true
Size: 951 Bytes
Versions: 16
Compression:
Stored size: 951 Bytes
Contents
const isArray = (value) => Array.isArray(value) const isBoolean = (str) => /^true/.test(str) || /^false/.test(str) const chdirTestApp = () => { try { return process.chdir('test/test_app') } catch (e) { return null } } const chdirCwd = () => process.chdir(process.cwd()) const resetEnv = () => { process.env = {} } const ensureTrailingSlash = (path) => (path.endsWith('/') ? path : `${path}/`) const resolvedPath = (packageName) => { try { return require.resolve(packageName) } catch (e) { if (e.code !== 'MODULE_NOT_FOUND') { throw e } return null } } const moduleExists = (packageName) => (!!resolvedPath(packageName)) const canProcess = (rule, fn) => { const modulePath = resolvedPath(rule) if (modulePath) { return fn(modulePath) } return null } module.exports = { chdirTestApp, chdirCwd, isArray, isBoolean, ensureTrailingSlash, canProcess, moduleExists, resetEnv }
Version data entries
16 entries across 16 versions & 2 rubygems