Giter Site home page Giter Site logo

gruntfile-editor's Introduction

Gruntfile Editor

npm tests dependencies

An API to modify a Gruntfile.js content

Installation

npm install --save gruntfile-editor

Example

var GruntfileEditor = require('gruntfile-editor');
var editor = new GruntfileEditor();

editor.insertConfig('compass', '{ foo: "bar" }');

fs.writeFileSync('Gruntfile.js', editor.toString());

API

new GruntfileEditor( content )

Create a new editor instance. You can pass the content of the Gruntfile to edit to the constructor. If no content is provided, a default file structure is used.

editor.insertConfig( name, config )

Insert a configuration block inside the grunt.initConfig() call.

editor.registerTask( name, tasks )

Register a task inside a named task group

editor.registerTask('build', 'compass');
// output: grunt.registerTask('build', ['compass']);

editor.registerTask('build', ['compass', 'uglify']);
// output: grunt.registerTask('build', ['compass', 'uglify']);

editor.insertVariable( name, value )

Insert a variable to the top of the Gruntfile.

editor.insertVariable('root', '"project/foo"');
// output: var root = 'project/foo';

editor.prependJavaScript( code )

Insert a piece of arbritary JavaScript code to the top of the Gruntfile.

editor.prependJavaScript('require(\'load-grunt-tasks\')(grunt);');
// output: require('load-grunt-tasks')(grunt);

editor.loadNpmTasks( pluginName )

Load a Grunt plugin.

editor.loadNpmTasks('grunt-contrib-uglify');
// output: grunt.loadNpmTasks("grunt-contrib-uglify");

editor.loadNpmTasks(['grunt-contrib-uglify', 'grunt-contrib-concat']);
// output:
// grunt.loadNpmTasks("grunt-contrib-concat");
// grunt.loadNpmTasks("grunt-contrib-uglify");

editor.toString()

Returns the modified Gruntfile as a string.

Licence

Copyright (c) 2012 Simon Boudrias (twitter: @vaxilart)
Licensed under the MIT license.

gruntfile-editor's People

Contributors

eddiemonge avatar edoput avatar lauterry avatar sboudrias avatar sindresorhus avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.