limepot-xyz/BETA/mybulma/node_modules/@npmcli/fs/lib/with-owner.js
LimePot 76722fec47 Beta Site
Going to slowly work on a Bulma site, which will end up being the main site.

Currently under the /BETA/ folder so Alpha site will still be main site.
2022-12-20 16:23:37 -07:00

21 lines
495 B
JavaScript

const getOptions = require('./common/get-options.js')
const owner = require('./common/owner.js')
const withOwner = async (path, fn, opts) => {
const options = getOptions(opts, {
copy: ['owner'],
})
const { uid, gid } = await owner.validate(path, options.owner)
const result = await fn({ uid, gid })
await Promise.all([
owner.update(path, uid, gid),
typeof result === 'string' ? owner.update(result, uid, gid) : null,
])
return result
}
module.exports = withOwner