UNPKG

3.89 kBMarkdownView Raw
1# viralify [![build status](https://secure.travis-ci.org/thlorenz/viralify.png)](http://travis-ci.org/thlorenz/viralify)
2
3Injects one or more browserify transforms into all dependencies of a package recursively.
4
5```sh
6viralify . -t browserify-swap
7```
8
9```js
10var viralify = require('viralify');
11
12viralify(root, 'browserify-swap', function (err) {
13 if (err) return console.error(err);
14 // package.json's found in root and below now have 'browserify-swap' added
15 // to the end of their 'browserify.transform' field
16})
17```
18
19## Installation
20
21 npm install viralify
22
23## Usage
24
25```
26viralify <path> <options>
27
28 Inject browserify transform(s) into the package.json files of all packages at and below the given path.
29
30OPTIONS:
31
32 -t, --transform transform(s) to inject
33 -f, --front if set, the transform(s) are injected in the front of the transform field so they run first
34
35EXAMPLES:
36
37 Inject 'browserify-swap' transform for package in current directory and all its dependencies
38
39 viralify . -t browserify-swap
40
41 Inject 'envify' and 'es6ify' transforms in front for all dependencies found in ./node_modules
42
43 viralify ./node_modules --transform envify --transform es6ify --front
44```
45## API
46
47<!-- START docme generated API please keep comment here to allow auto update -->
48<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN docme TO UPDATE -->
49
50<div>
51<div class="jsdoc-githubify">
52<section>
53<article>
54<div class="container-overview">
55<dl class="details">
56</dl>
57</div>
58<dl>
59<dt>
60<h4 class="name" id="viralify"><span class="type-signature"></span>viralify<span class="signature">(root, transform, <span class="optional">front</span>, cb)</span><span class="type-signature"></span></h4>
61</dt>
62<dd>
63<div class="description">
64<p>Injects the given transform(s) into the <code>browserify.transform</code> field of all <code>package.json</code>s
65at and below the given <code>root</code>.</p>
66<p>If the transform(s) were contained in the <code>package.json</code> already, no changes are made and no writes performed.
67This means that all viralify runs succeeding the first one will be much faster than the first.</p>
68</div>
69<h5>Parameters:</h5>
70<table class="params">
71<thead>
72<tr>
73<th>Name</th>
74<th>Type</th>
75<th>Argument</th>
76<th class="last">Description</th>
77</tr>
78</thead>
79<tbody>
80<tr>
81<td class="name"><code>root</code></td>
82<td class="type">
83<span class="param-type">String</span>
84</td>
85<td class="attributes">
86</td>
87<td class="description last"><p>of the package</p></td>
88</tr>
89<tr>
90<td class="name"><code>transform</code></td>
91<td class="type">
92<span class="param-type">Array.&lt;String></span>
93</td>
94<td class="attributes">
95</td>
96<td class="description last"><p>one or more transforms to be added to the transform field</p></td>
97</tr>
98<tr>
99<td class="name"><code>front</code></td>
100<td class="type">
101<span class="param-type">Boolean</span>
102</td>
103<td class="attributes">
104&lt;optional><br>
105</td>
106<td class="description last"><p>if set transforms are added to the front of the transform field so they run first</p></td>
107</tr>
108<tr>
109<td class="name"><code>cb</code></td>
110<td class="type">
111<span class="param-type">function</span>
112</td>
113<td class="attributes">
114</td>
115<td class="description last"><p>called when the transform injection is complete</p></td>
116</tr>
117</tbody>
118</table>
119<dl class="details">
120<dt class="tag-source">Source:</dt>
121<dd class="tag-source"><ul class="dummy">
122<li>
123<a href="https://github.com/thlorenz/viralify/blob/master/index.js">index.js</a>
124<span>, </span>
125<a href="https://github.com/thlorenz/viralify/blob/master/index.js#L50">lineno 50</a>
126</li>
127</ul></dd>
128</dl>
129</dd>
130</dl>
131</article>
132</section>
133</div>
134
135*generated with [docme](https://github.com/thlorenz/docme)*
136</div>
137<!-- END docme generated API please keep comment here to allow auto update -->
138
139#### viralify.sync(root, transform, front)
140
141Same as `viralify` but performed synchronously.
142
143## License
144
145MIT
146