refactor(Cypress): Moved Cypress to the main folder of the project, as I don't need a sub project for now.
This commit is contained in:
41
node_modules/cypress/lib/tasks/get-folder-size.js
generated
vendored
Normal file
41
node_modules/cypress/lib/tasks/get-folder-size.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
|
||||
const fs = require('../fs');
|
||||
|
||||
const {
|
||||
join
|
||||
} = require('path');
|
||||
|
||||
const Bluebird = require('bluebird');
|
||||
/**
|
||||
* Get the size of a folder or a file.
|
||||
*
|
||||
* This function returns the actual file size of the folder (size), not the allocated space on disk (size on disk).
|
||||
* For more details between the difference, check this link:
|
||||
* https://www.howtogeek.com/180369/why-is-there-a-big-difference-between-size-and-size-on-disk/
|
||||
*
|
||||
* @param {string} path path to the file or the folder.
|
||||
*/
|
||||
|
||||
|
||||
async function getSize(path) {
|
||||
const stat = await fs.lstat(path);
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
const list = await fs.readdir(path);
|
||||
return Bluebird.resolve(list).reduce(async (prev, curr) => {
|
||||
const currPath = join(path, curr);
|
||||
const s = await fs.lstat(currPath);
|
||||
|
||||
if (s.isDirectory()) {
|
||||
return prev + (await getSize(currPath));
|
||||
}
|
||||
|
||||
return prev + s.size;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
return stat.size;
|
||||
}
|
||||
|
||||
module.exports = getSize;
|
Reference in New Issue
Block a user