0.5.0 • Published 6 years ago

ember-cli-file-creator v0.5.0

Weekly downloads
147
License
MIT
Repository
github
Last release
6 years ago

ember-cli-file-creator Build Status Build status

Add a file into the ember app tree.

This is useful for transforming arbitrary data into a consumable format.

Usage

npm install --save-dev ember-cli-file-creator
var package = require('package');

EmberApp.init({
	fileCreator: [
		{
			filename: '/service/build-details.js',
			content: 'export default {' + package.version + '}',
		}
	]
});

will result in

export default { 
	BUILD_VERSION: '1.2.3'
};

Available file options

OptionTypeDefault valueUse
filenameString(required)Where to put the file within the tree
contentString or function that returns a string(required)Content of the file
treeString"app"Name of the tree to put the file into

Available trees

  • app
  • styles
  • templates
  • vendor
  • test-support
  • public

See Ember CLI API docs for details.

Passing a function as content

You can specify a function that must return the content as a string.

EmberApp.init({
	fileCreator: [{
        filename: '/data/functional.js',
        content: function() {
            var testData = [1, 2, 3];
            return 'export default ' + JSON.stringify(testData) + ';';
        }
    }

will result in

export default [1, 2, 3];

Running

Contributing

  • jshint must pass
  • npm test must pass

Building

  • ember build

TODOs and next steps

  • add support for styles, templates & other

For more information on using ember-cli, visit http://www.ember-cli.com/.