Skip to content

Addon support: no coverage for addon files on Windows #48

Closed

Description

@nfc036

I did not get any coverage information for files within the addon subdirectory. This problem seems to be specific for windows environments. It seems, that the function here

 _doesFileExistIsCurrentProjectAddonModule: function(relativePath) {
    relativePath = path.join('addon', relativePath.replace(path.join('modules', this.project.pkg.name),''));

    if (this._existsSync(relativePath)) {
      return true;
    }

    return this._doesTemplateFileExist(relativePath);
  },

in index.js has problems with the path separator on Windows ("/" vs. ""). Inserting relativePath = path.join(relativePath); as the first line in this function seems to solve this issue but this is most probably not the best solution. (I am not an expert on this...)

Activity

  1. rwjblue commented on Oct 7, 2016

    @rwjblue
    Collaborator

    Lets break apart that line a bit, and update your local copy with the snippet below, then tell me what the console output values are..

      doesFileExistIsCurrentProjectAddonModule: function(_relativePath) {
        console.log('_relativePath', _relativePath);
        var relativePathWithoutProjectNamePrefix = relativePath.replace(path.join('modules', this.project.pkg.name), '');
        console.log('relativePathWithoutProjectNamePrefix', relativePathWithoutProjectNamePrefix);
    
        var relativePath = path.join('addon', relativePathWithoutProjectNamePrefix);
        console.log('relativePath', relativePath);
    
        if (this._existsSync(relativePath)) {
          return true;
        }
    
        return this._doesTemplateFileExist(relativePath);
      },

    I suspect, that we actually should be doing the following to cleanup/sanitize using / before checking _existsSync:

        var relativePathWithoutProjectNamePrefix = relativePath.replace('modules' + '/' +  this.project.pkg.name, '');
    
        var relativePath = 'addon/' + relativePathWithoutProjectNamePrefix;
        console.log('relativePath', relativePath);
  2. nfc036 commented on Oct 7, 2016

    @nfc036
    ContributorAuthor

    Hi Robert, thanks for looking into this. Here the output for one file:

    _relativePath modules/lib-ember-addon/transforms/tstamp.js
    relativePathWithoutProjectNamePrefix modules/lib-ember-addon/transforms/tstamp.js
    relativePath addon\modules\lib-ember-addon\transforms\tstamp.js
    
  3. nfc036 commented on Oct 7, 2016

    @nfc036
    ContributorAuthor

    Indeed, your second code snippet fixes the problem.

  4. rwjblue commented on Oct 7, 2016

    @rwjblue
    Collaborator

    Submitted #49 to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions