UNPKG

3.67 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</div>
67<h5>Parameters:</h5>
68<table class="params">
69<thead>
70<tr>
71<th>Name</th>
72<th>Type</th>
73<th>Argument</th>
74<th class="last">Description</th>
75</tr>
76</thead>
77<tbody>
78<tr>
79<td class="name"><code>root</code></td>
80<td class="type">
81<span class="param-type">String</span>
82</td>
83<td class="attributes">
84</td>
85<td class="description last"><p>of the package</p></td>
86</tr>
87<tr>
88<td class="name"><code>transform</code></td>
89<td class="type">
90<span class="param-type">Array.&lt;String></span>
91</td>
92<td class="attributes">
93</td>
94<td class="description last"><p>one or more transforms to be added to the transform field</p></td>
95</tr>
96<tr>
97<td class="name"><code>front</code></td>
98<td class="type">
99<span class="param-type">Boolean</span>
100</td>
101<td class="attributes">
102&lt;optional><br>
103</td>
104<td class="description last"><p>if set transforms are added to the front of the transform field so they run first</p></td>
105</tr>
106<tr>
107<td class="name"><code>cb</code></td>
108<td class="type">
109<span class="param-type">function</span>
110</td>
111<td class="attributes">
112</td>
113<td class="description last"><p>called when the transform injection is complete</p></td>
114</tr>
115</tbody>
116</table>
117<dl class="details">
118<dt class="tag-source">Source:</dt>
119<dd class="tag-source"><ul class="dummy">
120<li>
121<a href="https://github.com/thlorenz/viralify/blob/master/index.js">index.js</a>
122<span>, </span>
123<a href="https://github.com/thlorenz/viralify/blob/master/index.js#L35">lineno 35</a>
124</li>
125</ul></dd>
126</dl>
127</dd>
128</dl>
129</article>
130</section>
131</div>
132
133*generated with [docme](https://github.com/thlorenz/docme)*
134</div>
135<!-- END docme generated API please keep comment here to allow auto update -->
136
137#### viralify.sync(root, transform, front)
138
139Same as `viralify` but performed synchronously.
140
141## License
142
143MIT
144