ember-codemods / ember-test-helpers-codemod

Codemod to transform your Ember tests to use @ember/test-helpers
MIT License
29 stars 14 forks source link

"path argument is required" error when running this codemod #32

Open tomwayson opened 6 years ago

tomwayson commented 6 years ago

I'm running this codemod as part of ember-cli-update and I get the following error:

➜  ember-arcgis-server-services git:(chore/ember-3-5) ember-cli-update --run-codemods
? These codemods apply to your project. Select which ones to run. ember-test-h
elpers-codemod
npx: installed 383 in 9.299s

path argument is required

Usage: jscodeshift <path>... [options]

path     Files or directory to transform

Then it shows below:

Error: Command failed: /Users/tom/.npm/_npx/70046/lib/node_modules/ember-test-helpers-codemod/node_modules/jscodeshift/bin/jscodeshift.sh -t /Users/tom/.npm/_npx/70046/lib/node_modules/ember-test-helpers-codemod/transforms/integration/index.js --extensions js,ts
    at makeError (/Users/tom/.npm/_npx/70046/lib/node_modules/ember-test-helpers-codemod/node_modules/execa/index.js:172:9)
    at Promise.all.then.arr (/Users/tom/.npm/_npx/70046/lib/node_modules/ember-test-helpers-codemod/node_modules/execa/index.js:277:16)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

I'm upgrading my addon from 2.18 to 3.5 in steps for each minor (2.18 -> 3.0 -> 3.1 -> ...) and the above message is from after upgrading to 3.3, but I have seen the same message at each step that I've run this codemod on.

rinoldsimon commented 6 years ago

getting the same issue when upgrading from 3.4.3 to 3.5

simonihmig commented 5 years ago

It seems this happens when running the codemod automatically against a non-existing directory. For example I was able to reproduce this with an addon, that had /tests/integration but not /tests/acceptance. Running the codemod with the integration transforms worked, but for acceptance it failed with the exception shown above.

It seems this is what's happening:

  1. ember-cli-update runs both codemods without checking for the existence of the directories (https://github.com/ember-cli/ember-cli-update-codemods-manifest/blob/v2/manifest.json#L19-L20)
  2. codemod-cli does not check if the provided paths actually exist (I guess paths returned from globby is an empty array here: https://github.com/rwjblue/codemod-cli/blob/dd57dbaa2dade9f68aaeeed0410b9a2ae0d6046b/src/bin-support.js#L20)
  3. 💥

My approach would be to add a check to codemod-cli, and exit gracefully with a warning message if paths is empty.

Any other thoughts? /cc @rwjblue @kellyselden

rwjblue commented 5 years ago

Ya, seems good to me.

kellyselden commented 5 years ago

Does it make sense to infer all the options and instead run ember-test-helpers-codemod only?

xtagon commented 4 years ago

When I encountered this error, adding an empty tests/acceptance directory wasn't enough to fix it, but generating a new acceptance test did. Just sharing that in case anyone is in a similar situation