Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move Entire Folder using Broccoli JS in Ember CLI Project

I am developing an ember-cli project and I am working on a system that allows me to resolve templates that have not been loaded and may possibly live outside of the project structure.

I would like to have a folder in my dist/assets directory called templates and inside that folder would be all the pre compiled templates from app/templates/external. This is my current Brocfile.js attempt with broccoli stew

var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var stew = require("broccoli-stew");

var app = new EmberApp({
  vendorFiles: {
    "jquery.js": null
  },
  sassOptions: {
      includePaths: [
        'bower_components/bourbon/app/assets/stylesheets/',
        'bower_components/neat/app/assets/stylesheets/',
        'bower_components/bitters/app/assets/stylesheets/'
      ]
    }
});

var additionalTrees = [];

var templateFiles = stew.find(appTree, "assets/app/templates/external");
templateFiles = stew.mv(templateFiles, "assets/app/templates/external", "assets/templates");
additionalTrees.push(templateFiles);

module.exports = app.toTree(additionalTrees);
like image 728
BillPull Avatar asked Jun 17 '15 21:06

BillPull


1 Answers

There is npm package called broccoli-file-mover , easy to use , and can be found here

The usage is very simple , as easy as :

moveFile(inputTree, options)

can be used to move files ( multiple , or single ) , or whole folders

Example :

Moving a single file from app/main to app:

var moveFile = require('broccoli-file-mover');

var tree = moveFile('app', {
  srcFile: 'app/main.js',
  destFile: '/app.js'
});

Moving app/main to app and test/main to test:

var moveFile = require('broccoli-file-mover');

var tree = moveFile('app', {
  files: {
    'app/main.js': 'app.js',
    'test/main.js': 'test.js'
  }
});

Also , prior to blessnm comment broccoli funnel is a possible solution , as you can copy your directory to wherever you want ( thought the question states moving , but thought copying might be an acceptable solution ) , here is the repo of the plugin.

like image 76
ProllyGeek Avatar answered Oct 06 '22 04:10

ProllyGeek