Skip to content

Not working with ember-auto-import & absolute input paths #69

@mydea

Description

@mydea

I am currently trying to debug this issue:
fossasia/open-event-frontend#7971

I have a plugin that looks basically like this:

class CreateEmberL10nFastBootAssetMap extends Plugin {
  constructor(
    inputNode
  ) {
    super([inputNode], {});
  }

  build() {
    // We only support passing in one input path (for simplicity)
    this.inputPath = this.inputPaths[0];

    this.parseNode(this.inputPath);

    this.createFastBootAssetMapModule();
  }

  parseNode(inputPath) {
    let stat = this.input.statSync(inputPath);

    if (stat.isFile()) {
      this.parseFile(inputPath);
    } else if (stat.isDirectory()) {
      this.parseDirectory(inputPath);
    }
  }

  parseDirectory(inputPath) {
    let outputPath = this._getOutputPath(inputPath);
    if (!this.output.existsSync(outputPath)) {
      this.output.mkdirSync(outputPath);
    }

    let files = this.input.readdirSync(inputPath);
    files.forEach((file) => this.parseNode(path.join(inputPath, file)));
  }

  parseFile(inputPath) {
    let content = this.input.readFileSync(inputPath);
    let outputPath = this._getOutputPath(inputPath);

    // logic goes here
  }

  _getOutputPath(inputPath) {
    return path.relative(this.inputPath, inputPath);
  }
}

However, it seems that let inputPath = this.inputPaths[0]; is an absolute path to a temp directory here, e.g.:

/tmp/broccoli-3137903S9AmcZtiodI/out-0999-append_ember_auto_import_analyzer/

And this.input.readdirSync or this.input.readFileSync will convert that into e.g.

/tmp/broccoli-3137903S9AmcZtiodI/out-0999-append_ember_auto_import_analyzer//tmp/broccoli-3137903S9AmcZtiodI/out-0999-append_ember_auto_import_analyzer

Which obviously does not exist. To be honest I am not quite sure where that comes from exactly, but somewhere there seems to be a missing handling for absolute paths, I guess?

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