rsnext/packages/create-next-app/helpers/is-writeable.ts
matamatanot 0226e7872a
CNA: Add warning about permission (#14889)
close #14744

<img width="851" alt="screen_shot" src="https://user-images.githubusercontent.com/39780486/86603491-06bec800-bfdf-11ea-9928-ee85cbad86a7.png">


I have some concerns.

- `import { isWriteable } from '../next/build/is-writeable'` **not** from `create-next-app ` package.
- The warning sentence is from npm. Not for Next.js. I'm not a native English speaker. I'd like to know the natural expression for this.
2020-08-19 17:09:34 +00:00

10 lines
226 B
TypeScript

import fs from 'fs'
export async function isWriteable(directory: string): Promise<boolean> {
try {
await fs.promises.access(directory, (fs.constants || fs).W_OK)
return true
} catch (err) {
return false
}
}