-
Notifications
You must be signed in to change notification settings - Fork 404
chore: remove fs-extra #1271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: remove fs-extra #1271
Changes from all commits
4c72e36
2816458
be617a6
4569799
6c2a274
86b3ba4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ | |
'eslint', | ||
'execa', | ||
'find-up', | ||
'fs-extra', | ||
'globby', | ||
'log-symbols', | ||
'npm-packlist', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const fs = require('fs').promises | ||
const path = require('path') | ||
const rimraf = require('rimraf') | ||
const util = require('util') | ||
|
||
const rimrafAsync = util.promisify(rimraf) | ||
|
||
const copyDirRecursiveAsync = async (src, dest) => { | ||
try { | ||
fs.mkdir(dest, { recursive: true }) | ||
JCMais marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} catch (_) { | ||
// ignore erros for mkdir | ||
JCMais marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
const childrenItems = await fs.readdir(src) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has the potential to create a lot of promises. |
||
|
||
await Promise.all( | ||
childrenItems.map(async item => { | ||
const srcPath = path.join(src, item) | ||
const destPath = path.join(dest, item) | ||
|
||
const itemStat = await fs.lstat(srcPath) | ||
|
||
if (itemStat.isFile()) { | ||
fs.copyFile(srcPath, destPath) | ||
JCMais marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else { | ||
await copyDirRecursiveAsync(srcPath, destPath) | ||
} | ||
}) | ||
) | ||
} | ||
|
||
const ensureFilePathAsync = async filePath => { | ||
JCMais marked this conversation as resolved.
Show resolved
Hide resolved
|
||
try { | ||
await fs.mkdir(path.dirname(filePath), { recursive: true }) | ||
} catch (_) { | ||
JCMais marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// ignore any errors with mkdir - it will throw if the path already exists. | ||
} | ||
} | ||
|
||
const removeRecursiveAsync = async path => { | ||
await rimrafAsync(path) | ||
} | ||
|
||
module.exports = { | ||
copyDirRecursiveAsync, | ||
ensureFilePathAsync, | ||
removeRecursiveAsync, | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
const fs = require('fs-extra') | ||
const path = require('path') | ||
const execa = require('execa') | ||
const { fetchLatest, updateAvailable } = require('gh-release-fetch') | ||
|
||
const { NETLIFYDEVWARN } = require('../utils/logo') | ||
const fs = require('./fs') | ||
|
||
const isWindows = () => { | ||
return process.platform === 'win32' | ||
|
@@ -26,12 +27,13 @@ const isExe = (mode, gid, uid) => { | |
} | ||
|
||
const execExist = async binPath => { | ||
const binExists = await fs.exists(binPath) | ||
if (!binExists) { | ||
return false | ||
try { | ||
JCMais marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice cleanup! |
||
const stat = await fs.statAsync(binPath) | ||
return stat.isFile() && isExe(stat.mode, stat.gid, stat.uid) | ||
} catch (error) { | ||
if (error.code === 'ENOENT') return false | ||
throw error | ||
} | ||
const stat = fs.statSync(binPath) | ||
return stat && stat.isFile() && isExe(stat.mode, stat.gid, stat.uid) | ||
} | ||
|
||
const isVersionOutdated = async ({ packageName, currentVersion }) => { | ||
|
Uh oh!
There was an error while loading. Please reload this page.