Commit 9419535

Anton Medvedev <anton@medv.io>
2021-05-19 01:18:58
Remove uuid dependency
1 parent 95d5b21
Changed files (2)
package.json
@@ -17,7 +17,6 @@
     "chalk": "^4.1.1",
     "node-fetch": "^2.6.1",
     "shq": "^1.0.2",
-    "uuid": "^8.3.2",
     "which": "^2.0.2"
   },
   "publishConfig": {
zx.mjs
@@ -19,7 +19,6 @@ import os, {tmpdir} from 'os'
 import {promises as fs} from 'fs'
 import {createRequire} from 'module'
 import url from 'url'
-import {v4 as uuid} from 'uuid'
 import {$, cd, question, fetch, chalk, sleep, ProcessOutput} from './index.mjs'
 
 Object.assign(global, {
@@ -77,7 +76,7 @@ async function scriptFromStdin() {
     }
 
     if (script.length > 0) {
-      let filepath = join(tmpdir(), uuid() + '.mjs')
+      let filepath = join(tmpdir(), randomId() + '.mjs')
       await writeAndImport(filepath, script)
       return true
     }
@@ -113,3 +112,7 @@ async function importPath(filepath) {
   Object.assign(global, {__filename, __dirname, require})
   await import(url.pathToFileURL(filepath))
 }
+
+function randomId() {
+  return Math.random().toString(36).substr(2)
+}