-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add verbose
option
#7
Conversation
CI failed for
Should support for Node v0.12 get dropped or should the |
I will do it after this PR. Just ignore Node.js 0.12 failures for now. |
index.js
Outdated
args.push('/apps'); | ||
} | ||
|
||
if (Array.isArray(opts.filter)) { |
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.
I prefer to keep it Array
only. I don't like mixing types with little benefit.
readme.md
Outdated
|
||
Type: `boolean` | ||
|
||
Return verbose results (default: `false`). |
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.
Write the default value like done here: https://github.com/sindresorhus/boxen#borderstyle
readme.md
Outdated
status: 'Running', | ||
username: 'SINDRESORHU3930\\sindre' | ||
cpuTime: 0, // seconds | ||
windowTitle: 'Task Host Window' |
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.
I think it's useful for people to see the properties like this with values, so maybe add another example in the verbose
option section and show these.
- Make test cases check all properties - Revert making `memUsage` a `verbose` property (which it is not) - Revert making `filter` option accept strings - Add example to `verbose` option documentation - Change formatting of default values in documentation
I have made the changes you requested and even fixed a bug in my code. :)
|
Just noticed CI failed, and for good reason:
Gonna update the PR as soon as possible. :) |
Earlier CI failed on Node 0.12 with linting errors, now it failed on Node 4, too. |
@MarkTiedemann What's the status of this PR? :) |
Well, I (almost) forgot about the PR. ;) But thanks to your question, last night I spent 2-3 hours revisiting, upgrading, re-testing, fixing, and completely refactoring the old code. :) Not 100% happy with the results yet, and some documentation is still missing, but I'm probably gonna push the results in the next few days. PS: Last time I worked on this PR a couple of weeks ago, I created a streaming version of this module: tasklist-stream. I think once this PR is done, we could perhaps merge both in some way (they do "share" a lot of code already ...). |
This commit includes the following changes: - Update Node versions in appveyor.yml - Update dependencies - Use const instead of var - Use () => {} instead of function() {} - Remove Promise ponyfill - Remove 'N/A' check due to failure on non-English systems - Make the tests cases cover all returned tasks
@sindresorhus Here's my refactoring:
Hope you like it. :) |
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.
Looks really good. Just some minor nitpick.
test.js
Outdated
t.is(typeof d.pid, 'number'); | ||
t.is(typeof d.memUsage, 'number'); | ||
}); | ||
const makeTest = (options, t) => { |
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.
Can you use a test macro instead?
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.
Been using ava since .9, I totally missed that you support test macros now. Thanks for the advice!
test.js
Outdated
const makeTest = (options, t) => { | ||
return tasklist(options).then(tasks => { | ||
t.true(tasks.length > 0); | ||
tasks.forEach(task => { |
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.
Use a for-of loop.
test.js
Outdated
import test from 'ava'; | ||
import fn from './'; | ||
const test = require('ava'); | ||
const tasklist = require('./'); |
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.
Don't change this.
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.
I didn't like the inconsistency of having require statements in the index file and import statements in the test file. But I guess your plan is to change to import statements everywhere in the long run, so yeah, gladly changing it back. :)
package.json
Outdated
"ava": "*", | ||
"xo": "*" | ||
"ava": "^0.19.1", | ||
"xo": "^0.18.1" |
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.
Don't change this.
package.json
Outdated
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
"test": "xo --fix && ava --verbose" |
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.
Don't change this.
package.json
Outdated
@@ -10,10 +10,10 @@ | |||
"url": "sindresorhus.com" | |||
}, | |||
"engines": { | |||
"node": ">=0.10.0" | |||
"node": ">=4.0.0" |
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.
"node": ">=4"
test.js
Outdated
t.is(typeof d.memUsage, 'number'); | ||
}); | ||
const makeTest = (options, t) => { | ||
return tasklist(options).then(tasks => { |
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.
Use async/await
index.js
Outdated
args.push('/fi', el); | ||
}); | ||
if (Array.isArray(options.filter)) { | ||
options.filter.forEach(fi => args.push('/fi', fi)); |
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.
Use for-of loop.
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.
There was no for-loop before. I'm gladly changing it, but may I ask why?
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.
It's faster. I'm trying to use it over forEach whenever possible. So for consistency too. And I don't like inline arrow functions for things that doesn't return anything. Makes the code harder to read.
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.
Okay, I understand that. Thanks for explaining!
PS: I have fixed the requested changes. :)
index.js
Outdated
if (process.platform !== 'win32') { | ||
return Promise.reject(new Error('Windows only')); | ||
} | ||
|
||
opts = opts || {}; | ||
const options = opts || {}; |
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.
Don't change this. I have it like this so it will be super easy to change to default parameters when I can target Node.js 6.
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.
I didn't think about that. Thanks for explaining. :)
verbose
option
Looks great. Thank you @MarkTiedemann :) |
Would you be interested in being a maintainer here? I don't think this module requires much more work, so it's mostly just to highlight your contribution here in the readme. |
Yeah, sure. :) Thanks a lot! Well, there's some work I'd like to do here in the time to come:
|
Awesome! Could you put the above into an issue with checklists? |
Yeah, sure. See: #8. |
My first pull request. :)
verbose
option to improve performance (see: https://github.com/sindresorhus/tasklist/issues/6apps
option (to return only Windows Store Apps)filter
option accept not only a filter array, but also a single filter string