CINXE.COM
grunt - Grunt: The JavaScript Task Runner
<!DOCTYPE html><html lang="en" prefix="og: http://ogp.me/ns#" itemscope itemtype="http://schema.org/WebPage"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><title>grunt - Grunt: The JavaScript Task Runner</title><link rel="stylesheet" href="/css/main.css"><link rel="apple-touch-icon" href="/img/favicons/apple-touch-icon.png" sizes="180x180"><link rel="icon" type="image/png" href="/img/favicons/favicon-32x32.png" sizes="32x32"><link rel="icon" type="image/png" href="/img/favicons/favicon-16x16.png" sizes="16x16"><link rel="manifest" href="/img/favicons/manifest.json"><link rel="mask-icon" href="/img/favicons/safari-pinned-tab.svg" color="#e48632"><link rel="shortcut icon" href="/img/favicons/favicon.ico" type="image/x-icon"><meta name="msapplication-config" content="/img/favicons/browserconfig.xml"><meta name="theme-color" content="#e48632"><meta property="og:title" content="grunt - Grunt: The JavaScript Task Runner"><meta property="og:type" content="website"><meta property="og:url" content="https://gruntjs.com/"><meta property="og:image" content="https://gruntjs.com/img/og.png"><meta property="og:image:type" content="image/png"><meta property="og:image:width" content="256"><meta property="og:image:height" content="256"><meta name="twitter:card" content="summary_large_image"><meta name="twitter:creator" content="@gruntjs"><meta name="twitter:site" content="@gruntjs"><meta name="twitter:title" content="grunt - Grunt: The JavaScript Task Runner"><meta itemprop="name" content="Grunt"><meta itemprop="image" content="/img/og.png"><link href="/rss" rel="alternate" title="Grunt Blog Feed" type="application/atom+xml"></head><body class="page-api page-secondary"><div class="banner"> <a href="support">V1.6.1 is the current version, and previous versions are not supported. Upgrade to the latest version or consider other support options.</a></div><div class="navbar navbar-inverse"><div class="navbar-inner"><div class="container"><a class="brand" href="/"><span class="logo"></span></a><div class="nav-collapse collapse"><ul class="nav"><li><a href="/getting-started"><i class="icon-arrow-right"></i><span>Getting Started</span></a></li><li><a href="/configuring-tasks"><i class="icon-cog"></i><span>Configuring Tasks</span></a></li><li><a href="/plugins"><i class="icon-power-cord"></i><span>Plugins</span></a></li><li><a href="/documentation"><i class="icon-file-text"></i><span>Documentation</span></a></li><li><a href="/support"><i class="icon-file-text"></i><span>Support</span></a></li></ul><form class="navbar-search pull-right"><input class="search-query" type="text" placeholder="Search"></form></div><!--.nav-collapse--></div></div></div><div class="content"><div class="container grunt"><div class="row-fluid"><div class="span9 page"><div class="hero-unit"><h1>grunt</h1><p>Grunt exposes all of its methods and properties on the <code>grunt</code> object that gets passed into the <code>module.exports</code> function exported in your <a href="/getting-started">Gruntfile</a>, Grunt plugin or in a <a href="/creating-tasks">tasks file</a>.</p> <p>Nearly all of the following methods are defined elsewhere, but are provided directly on the <code>grunt</code> object for convenience. See the individual api section docs for detailed explanations and examples.</p> <h2><a class="anchor" href="#config" id="config"></a>Config</h2> <h3><a class="anchor" href="#grunt.initconfig" id="grunt.initconfig"></a>grunt.initConfig</h3> <p><em>This method is an alias for the <a href="/grunt.config#grunt.config.init">grunt.config.init</a> method.</em></p> <h2><a class="anchor" href="#creating-tasks" id="creating-tasks"></a>Creating Tasks</h2> <h3><a class="anchor" href="#grunt.registertask" id="grunt.registertask"></a>grunt.registerTask</h3> <p><em>This method is an alias for the <a href="/grunt.task#grunt.task.registertask">grunt.task.registerTask</a> method.</em></p> <h3><a class="anchor" href="#grunt.registermultitask" id="grunt.registermultitask"></a>grunt.registerMultiTask</h3> <p><em>This method is an alias for the <a href="/grunt.task#grunt.task.registermultitask">grunt.task.registerMultiTask</a> method.</em></p> <h3><a class="anchor" href="#grunt.renametask" id="grunt.renametask"></a>grunt.renameTask</h3> <p><em>This method is an alias for the <a href="/grunt.task#grunt.task.renametask">grunt.task.renameTask</a> method.</em></p> <h2><a class="anchor" href="#loading-externally-defined-tasks" id="loading-externally-defined-tasks"></a>Loading Externally-Defined Tasks</h2> <h3><a class="anchor" href="#grunt.loadtasks" id="grunt.loadtasks"></a>grunt.loadTasks</h3> <p><em>This method is an alias for the <a href="/grunt.task#grunt.task.loadtasks">grunt.task.loadTasks</a> method.</em></p> <h3><a class="anchor" href="#grunt.loadnpmtasks" id="grunt.loadnpmtasks"></a>grunt.loadNpmTasks</h3> <p><em>This method is an alias for the <a href="/grunt.task#grunt.task.loadnpmtasks">grunt.task.loadNpmTasks</a> method.</em></p> <h2><a class="anchor" href="#warnings-and-fatal-errors" id="warnings-and-fatal-errors"></a>Warnings and Fatal Errors</h2> <h3><a class="anchor" href="#grunt.warn" id="grunt.warn"></a>grunt.warn</h3> <p><em>This method is an alias for the <a href="/grunt.fail#grunt.fail.warn">grunt.fail.warn</a> method.</em></p> <h3><a class="anchor" href="#grunt.fatal" id="grunt.fatal"></a>grunt.fatal</h3> <p><em>This method is an alias for the <a href="/grunt.fail#grunt.fail.fatal">grunt.fail.fatal</a> method.</em></p> <h2><a class="anchor" href="#command-line-options" id="command-line-options"></a>Command-line Options</h2> <h3><a class="anchor" href="#grunt.option" id="grunt.option"></a>grunt.option</h3> <p>Retrieve the value of a command-line option, eg. <code>debug</code>. Note that for each command-line option, the inverse can be tested, eg. <code>no-debug</code>.</p> <pre><code class="lang-js">grunt.option(optionName)</code></pre> <h2><a class="anchor" href="#miscellaneous" id="miscellaneous"></a>Miscellaneous</h2> <h3><a class="anchor" href="#grunt.package" id="grunt.package"></a>grunt.package</h3> <p>The current Grunt <code>package.json</code> metadata, as an object.</p> <pre><code class="lang-js">grunt.package</code></pre> <h3><a class="anchor" href="#grunt.version" id="grunt.version"></a>grunt.version</h3> <p>The current Grunt version, as a string. This is just a shortcut to the <code>grunt.package.version</code> property.</p> <pre><code class="lang-js">grunt.version</code></pre> <div class="end-link">Found an error in the documentation? <a href='https://github.com/gruntjs/grunt-docs/issues'>File an issue</a>.</div></div></div><div class="span3"><div class="well sidebar-nav"><ul class="nav nav-list"><li class="nav-header"><i class="icon-cog"></i><span>API</span></li><li><a class="active" href="/api/grunt">grunt</a></li><li><a href="/api/grunt.config">grunt.config</a></li><li><a href="/api/grunt.event">grunt.event</a></li><li><a href="/api/grunt.fail">grunt.fail</a></li><li><a href="/api/grunt.file">grunt.file</a></li><li><a href="/api/grunt.log">grunt.log</a></li><li><a href="/api/grunt.option">grunt.option</a></li><li><a href="/api/grunt.task">grunt.task</a></li><li><a href="/api/grunt.template">grunt.template</a></li><li><a href="/api/grunt.util">grunt.util</a></li></ul><ul class="nav nav-list"><li class="nav-header"><span>Other</span></li><li><a href="/api/inside-tasks">Inside Tasks</a></li><li><a href="/api/exit-codes">Exit Codes</a></li></ul></div></div></div></div></div><footer class="grunt-footer"><div class="inner"><div class="container"><ul class="pull-right"><li><a href="/blog">Blog</a></li><li><a href="/upgrading-from-0.3-to-0.4">Migration Guides</a></li><li><a href="/contributing">Contributing</a></li><li><a href="/development-team">Development Team</a></li><li class="social"><a href="https://github.com/gruntjs/" title="Grunt on GitHub"><span class="icon-github"></span></a></li><li class="social"><a href="https://twitter.com/gruntjs/" title="Grunt on Twitter"><span class="icon-twitter"></span></a></li><li class="social"><a href="/rss" title="Grunt blog RSS feed"><span class="icon-rss"></span></a></li><li class="openjs"><a href="https://openjsf.org/" title="OpenJS Foundation"><img src="/img/openjsf-color-textw.svg" alt="OpenJS Foundation" width="100" height="31"></a></li></ul></div></div></footer></body></html>