Search code examples
javascriptember.jsember-cli

Prevent directory clean in Ember-CLI


I am using ember-cli from within a Java project. I am trying to build into a directory other than dist/. I am setting the path using "output-path": "../src/main/resources" in .ember-cli. The project is building and being output into the proper directory. The problem is that this directory has other things in it that are being cleaned when I do the ember build.

Is there a way to stop the clean, or better yet, to white list some files and directories?


Solution

  • Based on the CLI code, it seems it is not possible.

    https://github.com/ember-cli/ember-cli/blob/master/lib/models/builder.js#L50

      /**
        This is used to ensure that the output path is emptied, but not deleted
        itself. If we simply used `remove(this.outputPath)`, any symlinks would
        now be broken. This iterates the direct children of the output path,
        and calls `remove` on each (this preserving any symlinks).
      */
      clearOutputPath: function() {
        var outputPath = this.outputPath;
        if (!fs.existsSync(outputPath)) { return Promise.resolve();}
    
        if(!this.canDeleteOutputPath(outputPath)) {
          return Promise.reject(new SilentError('Using a build destination path of `' + outputPath + '` is not supported.'));
        }
    
        var promises = [];
        var entries = fs.readdirSync(outputPath);
    
        for (var i = 0, l = entries.length; i < l; i++) {
          promises.push(remove(path.join(outputPath, entries[i])));
        }
    
        return Promise.all(promises);
      }