therealklanni / bower-migrate

Migrate packages from bower.json to package.json
10 stars 0 forks source link

migrate skips dependencies key if it doesn't already in the package.json #58

Open skoblenick opened 7 years ago

skoblenick commented 7 years ago

Scenario: 1 . Have a bower.json with dependencies and devDependencies.

  1. Have a package.json with devDependencies and without dependencies (key doesn't exist)
  2. Run bower-migrate

Actual Result: The migration copies in the devDependencies but doesn't create a dependencies key in package.json which results in none of the dependencies being migrated.

Work Around: Add the dependencies key to the package.json set to an empty literal and re-run.

Expected Behavior: Both dependencies and devDependencies would be created in the package.json regardless if they exist or not.

daniloarcidiacono commented 7 years ago

The mistake is here:

var _pkgJson$dependencies = pkgJson.dependencies;
var outDeps = _pkgJson$dependencies === undefined ? {} : _pkgJson$dependencies;

when dependenciesis undefinedin pkgJson, outDeps is initialized to an empty object which is not referenced by _pkgJson; same thing goes for devDependencies. The bug stems from the fact pkgJson is first modified and then exported:

var newPkg = pkgJson;

I think that creating a new object from scratch (rather than modifying the existing one through variable aliases) would be a better approach.

therealklanni commented 7 years ago

I don't think referencing the transpiled code is going to be all that useful for debugging, but I appreciate your effort.

I will look into the issue when I have time, if nobody else submits a PR that fixes it before then. Thanks.