Socket
Socket
Sign inDemoInstall

gruntfile-editor

Package Overview
Dependencies
86
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gruntfile-editor

API to modify the content of a Gruntfile.js file


Version published
Maintainers
1
Install size
2.81 MB
Created

Readme

Source

Gruntfile Editor

npm tests Coverage Status 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']);

You can specify an optional description.

editor.registerTask('build', 'A task description', ['compass', 'uglify']);
// output: grunt.registerTask('build', 'A task description', ['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.

Keywords

FAQs

Last updated on 20 Nov 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc