Closed mekalag closed 3 years ago
You were missing a parameter, see our Usage
section, I believe it is suppose to be this way:
npx jscodeshift -t ./node_modules/@wdio/codemod/protractor ./test/steps/baseSteps.js
Please let me know if you have further questions.
Unfortunately, using -t parameter dint help. Its still throws env: node\r: No such file or directory
.
For reference, I think this is an upstream issue with jscodeshift
: https://github.com/facebook/jscodeshift/issues/424
It would be helpful to update the docs to indicate that the workaround described here https://github.com/facebook/jscodeshift/issues/424#issuecomment-888243971 works.
@kliph-gladly mind raising a PR?
I've encountered larger issues with the @wdio/codemod/async
adding the await
keyword to function calls for functions that do not return promises and failing to add async
to anonymous inline functions. I anticipate that I won't be using this in the future.
You will only need the codemod package as utility to rewrite your tests.
Thanks. Yes I'm aware. The larger issue that I mentioned is that the utility produces code with syntax errors.
Can you provide a code example that causes a syntax error when rewriting the code with this codemod?
Sure:
const foo = function() {
mySyncFunctionDoesNotReturnAPromiseOrEvenExist();
};
produces
const foo = function() {
await mySyncFunctionDoesNotReturnAPromiseOrEvenExist();
};
This is syntactically incorrect for two reasons. The outer function context is not async
so it doesn't make sense to use await
within it. And the function called in the inner scope does not return a promise, so it doesn't make sense to use await
.
Yep, this is a bug, mind raising a new issue for it?
Will do. Thank you.
Hi everyone, I am trying to transform a file called baseSteps.js to webdriverIO file using command
npx jscodeshift ../node_modules/\@wdio/codemod/protractor/ test/steps/baseSteps.js
Before this i have installed : npm install --save-dev @wdio/cli npx wdio config (ran the configuration wizard) I have configured cucumber framework.
After which I ran npx jscodeshift ../node_modules/\@wdio/codemod/protractor/ test/steps/baseSteps.js
In package.json I have all the dependencies
So when I run npx jscodeshift ../node_modules/\@wdio/codemod/protractor/ test/steps/baseSteps.js it throws : env: node\r: No such file or directory
Not sure what I am missing. though baseSteps.js file exists in test/steps folder. Can someone suggest?
Note: I am using mac OS. I was going through help in some other articles and I think this issue is caused by line endings with CRLF, where as its must be LF. For ex: https://github.com/mrmlnc/svg2sprite-cli/issues/4 and many more when we search for
env: node\r: No such file or directory
hopefully this will give an idea