-
Notifications
You must be signed in to change notification settings - Fork 15
enhance: Return a promise if not provide callback #4
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
Open
dreamdevil00
wants to merge
7
commits into
adriano-di-giovanni:master
Choose a base branch
from
dreamdevil00:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+116
−28
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8907ebb
enhance: Return a promise if not provide callback
dreamdevil00 bc01225
add support for windows(minimum support Windows Vista)
dreamdevil00 fe5fd54
merge support-windows
dreamdevil00 3f11f97
Update package.json
dreamdevil00 578e09f
add network dirvers
dreamdevil00 7bca52f
fix test script
dreamdevil00 b10c108
update version
dreamdevil00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| var format = require('./format') | ||
| var calcMultiplier = require('./calcMultiplier') | ||
|
|
||
| module.exports = function (stdout, options) { | ||
| // TODO: this should be removed because it never happens. | ||
| // Nonetheless, I want to consider it a breaking changed that's to be made after releasing 0.1.4 | ||
| if (!stdout) { | ||
| return void 0 | ||
| } | ||
|
|
||
| // TODO: `options.prefixMultiplier` should become `options.unit` | ||
| // I should deprecate the use of `options.prefixMultiplier` in 0.1.4 | ||
| var multiplier = calcMultiplier(options.prefixMultiplier) | ||
| var precision = options.precision | ||
| // TODO: `options.isDisplayPrefixMultiplier` should become `options.showUnit` | ||
| // I should deprecate the use of options.isDisplayPrefixMultiplier in 0.1.4 | ||
| var unit = options.isDisplayPrefixMultiplier ? options.prefixMultiplier : null | ||
|
|
||
| return stdout | ||
| .trim() | ||
| .split(/\r\r\n/) // split into rows | ||
| .slice(1) // strip column headers away | ||
| .map(function (row) { | ||
| var columns = row | ||
| .trim() | ||
| // one or more whitespaces followed by one or more digits | ||
| // must be interpreted as column delimiter | ||
| .replace(/\s+(\d+)/g, '\t$1') | ||
| // one or more whitespaces followed by a letter | ||
| // must be interpreted as column delimiter | ||
| .replace(/\s+([a-zA-Z])/g, '\t$1') | ||
| // comma followed by one or more whitespaces must be | ||
| // interpreted as the last column delimiter | ||
| .replace(/(\:)\s+/g, '$1\t') | ||
| // split into columns | ||
| .split(/\t/) | ||
| var size = parseInt(columns[3], 10) | ||
| var free = parseInt(columns[1], 10) | ||
| var used = size - free | ||
| var capacity = 1 - free / size | ||
| return { | ||
| filesystem: columns[0], | ||
| size: format(size, multiplier, precision, unit), | ||
| used: format(used, multiplier, precision, unit), | ||
| available: format(free, multiplier, precision, unit), | ||
| capacity: precision ? capacity.toFixed(precision) : capacity, | ||
| mount: columns[2], | ||
| } | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| 'use strict'; | ||
| // From loopback | ||
| // https://github.com/strongloop/loopback/blob/77a35231dc0e8a480feb5b8e9e48429ab5bdd037/lib/utils.js#L16 | ||
| exports.createPromiseCallback = function createPromiseCallback() { | ||
| var cb = null; | ||
| var promise = new Promise(function(resolve, reject) { | ||
| cb = function(err, data) { | ||
| if (err) { | ||
| return reject(err); | ||
| } | ||
| return resolve(data); | ||
| }; | ||
| }); | ||
| cb.promise = promise; | ||
| return cb; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,13 @@ | ||
| { | ||
| "name": "node-df", | ||
| "version": "0.1.4", | ||
| "name": "node-df-win-posix", | ||
| "version": "0.3.0", | ||
| "description": | ||
| "A cross-platform Node.js wrapper around the standard Unix computer program, df.", | ||
| "main": "lib/index.js", | ||
| "scripts": { | ||
| "precommit": "lint-staged", | ||
| "test:coverage": "npm test -- --coverage", | ||
| "test": "jest" | ||
| "test": "jest --env=node" | ||
| }, | ||
| "author": "Adriano Di Giovanni <[email protected]> (http://adrianodigiovanni.com/)", | ||
| "license": "MIT", | ||
|
|
@@ -31,15 +31,15 @@ | |
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/adriano-di-giovanni/node-df.git" | ||
| "url": "https://github.com/dreamdevil00/node-df.git" | ||
| }, | ||
| "keywords": ["node", "df", "disk", "free", "diskfree"], | ||
| "bugs": { | ||
| "url": "https://github.com/adriano-di-giovanni/node-df/issues" | ||
| "url": "https://github.com/dreamdevil00/node-df/issues" | ||
| }, | ||
| "lint-staged": { | ||
| "*.js": ["eslint --fix", "git add"], | ||
| "*.json": ["prettier --write", "git add"] | ||
| }, | ||
| "homepage": "https://github.com/adriano-di-giovanni/node-df" | ||
| "homepage": "https://github.com/dreamdevil00/node-df.git" | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be included in the pull request