Skip to content

Commit

Permalink
Code style
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Apr 15, 2022
1 parent 7a979d5 commit a220c5e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
8 changes: 7 additions & 1 deletion src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ export function registerGlobals() {
}

export function $(pieces, ...args) {
let {verbose, shell, prefix, spawn, maxBuffer = 200 * 1024 * 1024 /* 200 MiB*/} = $
let {
verbose,
shell,
prefix,
spawn,
maxBuffer = 200 * 1024 * 1024 /* 200 MiB*/
} = $
let __from = (new Error().stack.split(/^\s*at\s/m)[2]).trim()
let cwd = process.cwd()

Expand Down
6 changes: 4 additions & 2 deletions test/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ test('Can use array as an argument', async () => {
test('Quiet mode is working', async () => {
let stdout = ''
let log = console.log
console.log = (...args) => {stdout += args.join(' ')}
console.log = (...args) => {
stdout += args.join(' ')
}
await quiet($`echo 'test'`)
console.log = log
assert(!stdout.includes('echo'))
Expand Down Expand Up @@ -131,7 +133,7 @@ test('question', async () => {
test('ProcessPromise', async () => {
let contents = ''
let stream = new Writable({
write: function(chunk, encoding, next) {
write: function (chunk, encoding, next) {
contents += chunk.toString()
next()
}
Expand Down
16 changes: 10 additions & 6 deletions test/test-utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const log = (name, group, err, file = '') => {
console.log(err)
console.log(file)
}
console.log('\n' + chalk[ err ? 'bgRedBright' : 'bgGreenBright' ].black(`${chalk.inverse(' ' + group + ' ')} ${name} `))
console.log('\n' + chalk[err ? 'bgRedBright' : 'bgGreenBright'].black(`${chalk.inverse(' ' + group + ' ')} ${name} `))
}

export const test = async function (name, cb, ms, focus, skip) {
Expand All @@ -61,7 +61,7 @@ export const test = async function (name, cb, ms, focus, skip) {
passed++
log(name, group)
} else {
skipped ++
skipped++
}
} catch (e) {
log(name, group, e, file)
Expand All @@ -76,9 +76,13 @@ export const test = async function (name, cb, ms, focus, skip) {
}
}

export const only = async function (name, cb, ms) { return test.call(this, name, cb, ms, true, false) }
export const only = async function (name, cb, ms) {
return test.call(this, name, cb, ms, true, false)
}

export const skip = async function (name, cb, ms) { return test.call(this, name, cb, ms, false, true) }
export const skip = async function (name, cb, ms) {
return test.call(this, name, cb, ms, false, true)
}

export const testFactory = (group, meta) => Object.assign(
test.bind({group, meta}), {
Expand All @@ -93,8 +97,8 @@ export const printTestDigest = () => {
console.log('\n' +
chalk.black.bgYellowBright(` zx version is ${require('../package.json').version} `) + '\n' +
chalk.greenBright(` 🍺 tests passed: ${passed} `) +
(skipped ? chalk.yellowBright (`\n 🚧 skipped: ${skipped} `) : '') +
(failed ? chalk.redBright (`\n ❌ failed: ${failed} `) : '')
(skipped ? chalk.yellowBright(`\n 🚧 skipped: ${skipped} `) : '') +
(failed ? chalk.redBright(`\n ❌ failed: ${failed} `) : '')
)
failed && process.exit(1)
}
6 changes: 3 additions & 3 deletions zx.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ async function importPath(filepath, origin = filepath) {
let ext = extname(filepath)

if (ext === '') {
let tmpFilename = fs.existsSync(`${filepath}.mjs`) ?
`${basename(filepath)}-${Math.random().toString(36).substr(2)}.mjs` :
`${basename(filepath)}.mjs`
let tmpFilename = fs.existsSync(`${filepath}.mjs`) ?
`${basename(filepath)}-${Math.random().toString(36).substr(2)}.mjs` :
`${basename(filepath)}.mjs`

return await writeAndImport(
await fs.readFile(filepath),
Expand Down

0 comments on commit a220c5e

Please sign in to comment.