Commit a220c5e

Anton Medvedev <anton@medv.io>
2022-04-15 13:58:28
Code style
1 parent 7a979d5
src/index.mjs
@@ -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()
 
test/index.test.mjs
@@ -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'))
@@ -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()
     }
test/test-utils.mjs
@@ -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) {
@@ -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)
@@ -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}), {
@@ -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)
 }
zx.mjs
@@ -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),