napi-rs/cli/src/utils.ts
LongYinan 67ad0a4d4d
feat(cli): upgrade clipanion v3
Remove napi new command
2021-08-07 00:23:17 +08:00

15 lines
508 B
TypeScript

import { readFile, writeFile, exists, copyFile, unlink } from 'fs'
import { promisify } from 'util'
export const readFileAsync = promisify(readFile)
export const writeFileAsync = promisify(writeFile)
export const existsAsync = promisify(exists)
export const unlinkAsync = promisify(unlink)
export const copyFileAsync = promisify(copyFile)
export function pick<O, K extends keyof O>(o: O, ...keys: K[]): Pick<O, K> {
return keys.reduce((acc, key) => {
acc[key] = o[key]
return acc
}, {} as O)
}