Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

remove gulp, fix ENOENT bug, typecheck stuff #84

Merged
merged 4 commits into from
Aug 24, 2022
Merged

Conversation

boneskull
Copy link
Contributor

See the commit messages for more detail

@boneskull boneskull self-assigned this Aug 9, 2022
@boneskull
Copy link
Contributor Author

boneskull commented Aug 9, 2022

I can also just extract the ENOENT fix into its own PR. It's in here because I found it when checking types.

lib/subprocess.js Outdated Show resolved Hide resolved
@boneskull boneskull requested a review from jlipps August 10, 2022 19:20
"@babel/preset-env",
{
"targets": {
"node": "14"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it ok to have min node version set separately for each module?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you're asking in this context, but generally speaking our minimum version is 14. in this case, it's @appium/support's minimum version, and that's a dependency of teen_process, so it can't be any older. Each project (not package) will necessarily have its own Babel config.

@@ -29,6 +30,31 @@
"lib",
"build/lib"
],
"scripts": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linking @KazuCocoa : this should probably be done for all other dependencies, so we could eventually completely get rid of gulp usage

@@ -120,7 +175,7 @@ class SubProcess extends EventEmitter {
// comes in chunks and a line could come in two different chunks, so
// we have logic to handle that case (using this.lastLinePortion to
// remember a line that started but did not finish in the last chunk)
for (const [streamName, streamData] of _.toPairs(streams)) {
for (const [streamName, streamData] of /** @type {[['stdout', string], ['stderr', string]]} */(_.toPairs(streams))) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, this cast is here because _.toPairs() is not strictly typed. the keys stdout and stderr in streams are string literals, meaning they cannot be anything else--however, _.toPairs() obliterates this and instead what we get back is of type [[string, string], [string, string]] which of course loses detail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Object.entries() (which would be comparable) also suffers from this. We can use Object.entries if we want, since we're targeting node.js v14

@@ -19,7 +17,7 @@ describe('exec', function () {
let {stdout, stderr, code} = await exec(cmd, args);
stdout.should.contain('exec-specs.js');
stderr.should.equal('');
code.should.equal(0);
should.equal(code, 0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to change because code is number|null, and if it is the latter, code.should.equal(0) would throw an exception, since null is not an object and certainly not one having a should property.

This PR removes gulp and adds much of the same tooling and strategies used by `appium`.

"New" stuff includes:

- Added `prettier` (but did not enable nor run it)
- Added type checks (but did not make part of build step)
- `lint-staged` for automatic `eslint --fix` as a pre-commit hook

Also sorted `package.json`
The `errno` property of a `NodeJS.ErrnoException` is always a `number`, and `code` is what we're looking for.  At some point the behavior changed, and this looks to have been a holdover from old Node.js versions.

The relevant test made too general of an assertion, which is partly why it was not noticed.
- Ensure various instance properties are guaranteed to be defined
- Ensure boolean-ness of various options
- Avoid deprecated `fs.R_OK`

When appium/appium#17345 is published and we upgrade `@appium/support`, `tsc` will pass and we can add it to the build.
@boneskull boneskull merged commit 8091d0c into main Aug 24, 2022
@boneskull boneskull deleted the boneskull/no-gulp branch April 19, 2023 20:58
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants