check-disk-space
Advanced tools
Comparing version 1.5.0 to 2.0.0
13
index.js
@@ -14,2 +14,3 @@ 'use strict' | ||
} | ||
util.inherits(InvalidPathError, Error) | ||
@@ -22,2 +23,3 @@ | ||
} | ||
util.inherits(NoMatchError, Error) | ||
@@ -44,2 +46,3 @@ | ||
} | ||
filtered = filtered[0] | ||
@@ -72,4 +75,4 @@ | ||
resolve(mapOutput(stdout, filter, mapping, coefficient)) | ||
} catch (err) { | ||
reject(err) | ||
} catch (error2) { | ||
reject(error2) | ||
} | ||
@@ -94,3 +97,3 @@ }) | ||
return check( | ||
`wmic logicaldisk get size,freespace,caption`, | ||
'wmic logicaldisk get size,freespace,caption', | ||
driveData => { | ||
@@ -140,4 +143,4 @@ // Only get the drive which match the path | ||
* | ||
* @param directoryPath | ||
* @returns {*} | ||
* @param {String} directoryPath - The file/folder path from where we want to know disk space | ||
* @returns {String} - The first existing parent path | ||
*/ | ||
@@ -144,0 +147,0 @@ module.exports.getFirstExistingParentPath = directoryPath => { |
{ | ||
"name": "check-disk-space", | ||
"version": "1.5.0", | ||
"description": "Light multiplartform disk space checker without third party for Node.js", | ||
"version": "2.0.0", | ||
"description": "Light multi-platform disk space checker without third party for Node.js", | ||
"main": "index.js", | ||
"engines" : { | ||
"node" : ">=8" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"ava": "0.22.0", | ||
"eslint-plugin-ava": "^4.2.2", | ||
"npm-run-all": "^4.1.1", | ||
"xo": "^0.18.2" | ||
"ava": "^2.0.0", | ||
"eslint": "^5.16.0", | ||
"eslint-plugin-ava": "^7.0.0", | ||
"npm-run-all": "^4.1.5", | ||
"xo": "^0.24.0" | ||
}, | ||
@@ -13,0 +17,0 @@ "xo": { |
28
test.js
@@ -130,3 +130,3 @@ 'use strict' | ||
// Clean some required paths | ||
delete require.cache[require.resolve('./')] | ||
delete require.cache[require.resolve('.')] | ||
@@ -143,3 +143,3 @@ // Forces the platform for test purposes | ||
return require('./') | ||
return require('.') | ||
} | ||
@@ -149,3 +149,3 @@ | ||
// Clean some required paths | ||
delete require.cache[require.resolve('./')] | ||
delete require.cache[require.resolve('.')] | ||
@@ -158,3 +158,3 @@ // Forces the platform for test purposes | ||
return require('./').getFirstExistingParentPath | ||
return require('.').getFirstExistingParentPath | ||
} | ||
@@ -172,21 +172,21 @@ | ||
test(`win32: path did not match any disk`, async t => { | ||
test('win32: path did not match any disk', async t => { | ||
const checkDiskSpace = mockCheckDiskSpace('win32', platformFixtures.win32[0]) | ||
const error = await t.throws(checkDiskSpace('Z:/shouldfail')) | ||
const error = await t.throwsAsync(checkDiskSpace('Z:/shouldfail')) | ||
t.is(error.name, 'NoMatchError') | ||
}) | ||
test(`win32: invalid path`, async t => { | ||
test('win32: invalid path', async t => { | ||
const checkDiskSpace = mockCheckDiskSpace('win32', platformFixtures.win32[0]) | ||
const error = await t.throws(checkDiskSpace('an invalid path')) | ||
const error = await t.throwsAsync(checkDiskSpace('an invalid path')) | ||
t.is(error.name, 'InvalidPathError') | ||
}) | ||
test(`unix: invalid path`, async t => { | ||
test('unix: invalid path', async t => { | ||
const checkDiskSpace = mockCheckDiskSpace('linux', platformFixtures.linux[0]) | ||
const error = await t.throws(checkDiskSpace('an invalid path')) | ||
const error = await t.throwsAsync(checkDiskSpace('an invalid path')) | ||
t.is(error.name, 'InvalidPathError') | ||
}) | ||
test(`exec has an error`, async t => { | ||
test('exec has an error', async t => { | ||
const fixture = JSON.parse(JSON.stringify(platformFixtures.win32[0])) | ||
@@ -196,7 +196,7 @@ fixture.execError = new Error('some error') | ||
const checkDiskSpace = mockCheckDiskSpace('win32', fixture) | ||
const error = await t.throws(checkDiskSpace('C:/something')) | ||
const error = await t.throwsAsync(checkDiskSpace('C:/something')) | ||
t.is(error.message, 'some error') | ||
}) | ||
test(`unix: get first existing parent path`, t => { | ||
test('unix: get first existing parent path', t => { | ||
const parentPath = '/home/Lisa' | ||
@@ -207,3 +207,3 @@ const getFirstExistingParentPath = mockGetFirstExistingParentPath(parentPath) | ||
test(`unix: get first parent can be the path itself`, t => { | ||
test('unix: get first parent can be the path itself', t => { | ||
const parentPath = '/home/Lisa' | ||
@@ -210,0 +210,0 @@ const getFirstExistingParentPath = mockGetFirstExistingParentPath(parentPath) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
193003
5
8