PHP 8.2.30
Preview: mkdtemp.js Size: 777 B
/opt/alt/alt-nodejs16/root/lib/node_modules/npm/node_modules/@npmcli/fs/lib/mkdtemp.js

const { dirname, sep } = require('path')

const fs = require('./fs.js')
const getOptions = require('./common/get-options.js')
const withOwner = require('./with-owner.js')

const mkdtemp = async (prefix, opts) => {
  const options = getOptions(opts, {
    copy: ['encoding'],
    wrap: 'encoding',
  })

  // mkdtemp relies on the trailing path separator to indicate if it should
  // create a directory inside of the prefix. if that's the case then the root
  // we infer ownership from is the prefix itself, otherwise it's the dirname
  // /tmp -> /tmpABCDEF, infers from /
  // /tmp/ -> /tmp/ABCDEF, infers from /tmp
  const root = prefix.endsWith(sep) ? prefix : dirname(prefix)

  return withOwner(root, () => fs.mkdtemp(prefix, options), opts)
}

module.exports = mkdtemp

Directory Contents

Dirs: 3 × Files: 10

Name Size Perms Modified Actions
common DIR
- drwxr-xr-x 2026-03-19 07:09:42
Edit Download
cp DIR
- drwxr-xr-x 2026-03-19 07:09:42
Edit Download
rm DIR
- drwxr-xr-x 2026-03-19 07:09:42
Edit Download
494 B lrw-r--r-- 2026-03-09 06:51:27
Edit Download
3.32 KB lrw-r--r-- 2026-03-09 06:51:27
Edit Download
660 B lrw-r--r-- 2026-03-09 06:51:27
Edit Download
395 B lrw-r--r-- 2026-03-09 06:51:27
Edit Download
435 B lrw-r--r-- 2026-03-09 06:51:27
Edit Download
777 B lrw-r--r-- 2026-03-09 06:51:27
Edit Download
463 B lrw-r--r-- 2026-03-09 06:51:27
Edit Download
495 B lrw-r--r-- 2026-03-09 06:51:27
Edit Download
1021 B lrw-r--r-- 2026-03-09 06:51:27
Edit Download
395 B lrw-r--r-- 2026-03-09 06:51:27
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).