Compare commits
596 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d96e4a6bf | ||
|
|
a00a3a7429 | ||
|
|
1c3585e5a2 | ||
|
|
214ce8853b | ||
|
|
d24dc662dc | ||
|
|
e8056ac460 | ||
|
|
429656bc41 | ||
|
|
b61445cbf4 | ||
|
|
603253b0cb | ||
|
|
5ee955bb62 | ||
|
|
83a0efb085 | ||
|
|
9306a9b3f0 | ||
|
|
59939d09e8 | ||
|
|
f9769e40dd | ||
|
|
9c44a3e4c7 | ||
|
|
5048a78376 | ||
|
|
814319d7c0 | ||
|
|
4b3d6f1760 | ||
|
|
56c40cfa3c | ||
|
|
fd9e01b7e6 | ||
|
|
5c7f08843d | ||
|
|
6e6c5c4e2a | ||
|
|
1c2c4788a2 | ||
|
|
b59ecb9e11 | ||
|
|
7551746e55 | ||
|
|
70ac1e7fa4 | ||
|
|
f130d02efc | ||
|
|
150aea21ec | ||
|
|
273f9d497a | ||
|
|
1c85068091 | ||
|
|
42786630a1 | ||
|
|
938feca6a9 | ||
|
|
3747735980 | ||
|
|
5dd2d7e5d4 | ||
|
|
65c2435418 | ||
|
|
0a695c5d2a | ||
|
|
8fe677a644 | ||
|
|
213ff003d0 | ||
|
|
986abbf5db | ||
|
|
a2da9abd6d | ||
|
|
9068dda110 | ||
|
|
6baa9a0918 | ||
|
|
b8fe75e93a | ||
|
|
78a5e3fadf | ||
|
|
5e54886cbc | ||
|
|
d7849054f8 | ||
|
|
708ac80a55 | ||
|
|
d341d5e535 | ||
|
|
eef12cc2b3 | ||
|
|
99c8b59a14 | ||
|
|
abdc3f3c21 | ||
|
|
401ac45568 | ||
|
|
61709c1f97 | ||
|
|
1a8479ed31 | ||
|
|
a703d3591f | ||
|
|
1fa2acf5a7 | ||
|
|
d5c0e94166 | ||
|
|
6dc602b521 | ||
|
|
1d37af162a | ||
|
|
781373f7ce | ||
|
|
68574cc7e8 | ||
|
|
0f3b06320e | ||
|
|
d181abb628 | ||
|
|
f5643dc7ea | ||
|
|
6bcac7f638 | ||
|
|
ad71389dcc | ||
|
|
8cbf149558 | ||
|
|
e7ada80d08 | ||
|
|
9912f7cc46 | ||
|
|
6e02e5a54c | ||
|
|
42b010775b | ||
|
|
1c50c5c7aa | ||
|
|
200a9aa97e | ||
|
|
4512337c11 | ||
|
|
55677dba4a | ||
|
|
ca43ca21f5 | ||
|
|
fafbeb8c59 | ||
|
|
d67f2b110d | ||
|
|
9c2127ce33 | ||
|
|
423629c38b | ||
|
|
5ec0ccec1b | ||
|
|
7a423b7bb4 | ||
|
|
a3de7f3222 | ||
|
|
55d892adc8 | ||
|
|
3b42df8d1d | ||
|
|
21fa84225c | ||
|
|
4895aebf0a | ||
|
|
8a29122d0a | ||
|
|
26ed7a003a | ||
|
|
00ca5288b0 | ||
|
|
6d2912a2ab | ||
|
|
1d61584402 | ||
|
|
f6974744cd | ||
|
|
7171cbed6f | ||
|
|
8f66273922 | ||
|
|
1a9ab82e24 | ||
|
|
3fa004293c | ||
|
|
83efa2288d | ||
|
|
4cfe62d3d1 | ||
|
|
802f064178 | ||
|
|
c49cb68575 | ||
|
|
0534872e0f | ||
|
|
f1b8cf8fd6 | ||
|
|
78ff9a2215 | ||
|
|
b952be6f56 | ||
|
|
638ae5c6fa | ||
|
|
a7b6495172 | ||
|
|
703e43cc2b | ||
|
|
03636878d1 | ||
|
|
2ee4b6f414 | ||
|
|
10305f0791 | ||
|
|
276c031c60 | ||
|
|
63f72b37df | ||
|
|
cf5bfecec4 | ||
|
|
77c3f20956 | ||
|
|
e4ada9fa43 | ||
|
|
a0de15d0f7 | ||
|
|
df4689fbd2 | ||
|
|
018e47bec0 | ||
|
|
74cc1eb022 | ||
|
|
eda8ffbcc4 | ||
|
|
b9383c9016 | ||
|
|
25c0be1e20 | ||
|
|
a8233eb68c | ||
|
|
ea198c9a19 | ||
|
|
e0537ce3df | ||
|
|
cce5df35ba | ||
|
|
7e269961c3 | ||
|
|
f214ffaf1f | ||
|
|
d016fe010a | ||
|
|
fb5a51b1b7 | ||
|
|
3e5037a1be | ||
|
|
60fec40613 | ||
|
|
fb215546ee | ||
|
|
4b593bcda2 | ||
|
|
8349f0ff48 | ||
|
|
bb250b5730 | ||
|
|
b6f1c156da | ||
|
|
4c9a36e9ad | ||
|
|
bb01513eba | ||
|
|
ba7f27dead | ||
|
|
79ec957ee7 | ||
|
|
d8b55652a5 | ||
|
|
4c38f507f5 | ||
|
|
f213167ef0 | ||
|
|
1da31aa425 | ||
|
|
519a9481e6 | ||
|
|
b16bf303ca | ||
|
|
9a28706688 | ||
|
|
a318ddf9b3 | ||
|
|
8dbbc32905 | ||
|
|
de03007348 | ||
|
|
1b22c2e2b1 | ||
|
|
0e1f2408c9 | ||
|
|
931cc45fc3 | ||
|
|
085e314a3f | ||
|
|
6aa45732d8 | ||
|
|
16c0be8314 | ||
|
|
578a601b27 | ||
|
|
896aa7c436 | ||
|
|
2441b00262 | ||
|
|
88595f09aa | ||
|
|
5925bd5e37 | ||
|
|
24e22dd8bc | ||
|
|
61de5f9ca3 | ||
|
|
4de9eff55c | ||
|
|
7e20a77c89 | ||
|
|
8fbbeb8fc5 | ||
|
|
79203ba5d0 | ||
|
|
2e3e48cc06 | ||
|
|
db8acf11fd | ||
|
|
a6be718387 | ||
|
|
e2c4c88136 | ||
|
|
4cd0b078d0 | ||
|
|
f6ba08253b | ||
|
|
0ecb2879b9 | ||
|
|
e3b84499c2 | ||
|
|
b313f62749 | ||
|
|
7f3a794d89 | ||
|
|
ba1be9b4ea | ||
|
|
652a9ef9b5 | ||
|
|
0d81a219ae | ||
|
|
d6e457354f | ||
|
|
6668dc5c47 | ||
|
|
3d9c1d7852 | ||
|
|
29f582611b | ||
|
|
673cda56c4 | ||
|
|
e562a5645b | ||
|
|
c0c5e8d7ef | ||
|
|
f00d688c87 | ||
|
|
5aa78f21cf | ||
|
|
4a7275a0c6 | ||
|
|
c77be55cdc | ||
|
|
e195fccdb7 | ||
|
|
87516039a8 | ||
|
|
80e349edb1 | ||
|
|
038c1f3d0f | ||
|
|
66455f7c77 | ||
|
|
a69eae10e3 | ||
|
|
13b87449e8 | ||
|
|
222250f2d1 | ||
|
|
77f4490391 | ||
|
|
0871131dfd | ||
|
|
e6bd207624 | ||
|
|
bad79e6d77 | ||
|
|
d07fa2db10 | ||
|
|
20953ab04c | ||
|
|
4cf940153c | ||
|
|
47bbf93f50 | ||
|
|
7976a1343f | ||
|
|
bf8abf1052 | ||
|
|
eb6031cb58 | ||
|
|
55a6f1f06e | ||
|
|
c188c1b11a | ||
|
|
b15ea07067 | ||
|
|
752c0e4ef1 | ||
|
|
49364532b3 | ||
|
|
9157cb4cfe | ||
|
|
6dde4aac38 | ||
|
|
96635cd2bd | ||
|
|
5342b6a04c | ||
|
|
2d0c025c49 | ||
|
|
6ed93f4c01 | ||
|
|
3c2719a85e | ||
|
|
c47f03f996 | ||
|
|
300022642a | ||
|
|
bce3abaa4b | ||
|
|
9f6280265a | ||
|
|
7211c9ee29 | ||
|
|
246caa8581 | ||
|
|
1fac49f887 | ||
|
|
d2422a623a | ||
|
|
fcc00b22b7 | ||
|
|
0787a55999 | ||
|
|
7c45d62b37 | ||
|
|
703acb0514 | ||
|
|
744507b83e | ||
|
|
ec7909dcd3 | ||
|
|
cf5f195d75 | ||
|
|
9f0520cdd0 | ||
|
|
d950c1a0ea | ||
|
|
6123fbcd31 | ||
|
|
def7ec5364 | ||
|
|
52a384a0cc | ||
|
|
ba1e2f1cdf | ||
|
|
625e54880f | ||
|
|
cebda7d35a | ||
|
|
4a9a15c404 | ||
|
|
31c5406780 | ||
|
|
a34c080d77 | ||
|
|
0b97ee1d2a | ||
|
|
1ded21c10d | ||
|
|
e30424d22f | ||
|
|
78e7aa6b67 | ||
|
|
ae4c841742 | ||
|
|
4f9324c439 | ||
|
|
020f61500f | ||
|
|
38a0c997e2 | ||
|
|
70f1734c12 | ||
|
|
1d40a5bc8b | ||
|
|
db4c582d79 | ||
|
|
e46ee7b30b | ||
|
|
f82f38be90 | ||
|
|
3a21485050 | ||
|
|
e6887d500f | ||
|
|
472d23b990 | ||
|
|
1a19de9d20 | ||
|
|
f3d1770e3e | ||
|
|
ba2a850253 | ||
|
|
618a372f38 | ||
|
|
a09a028c38 | ||
|
|
d78905988e | ||
|
|
8cceae3cc1 | ||
|
|
192e381971 | ||
|
|
966ff0e1b0 | ||
|
|
b90a0a811e | ||
|
|
25ca41c9dc | ||
|
|
0d44ed1126 | ||
|
|
dc53a37d4f | ||
|
|
332ae1afcb | ||
|
|
9108a7f7fa | ||
|
|
3b21b76106 | ||
|
|
dcba513108 | ||
|
|
e6a5374bfb | ||
|
|
8cba9c5781 | ||
|
|
1d6145de5a | ||
|
|
ca0c8a7f1d | ||
|
|
21771e7369 | ||
|
|
a3331ffdb0 | ||
|
|
4a5f5203d0 | ||
|
|
ee6d4ab074 | ||
|
|
8925419e90 | ||
|
|
0f709eafa0 | ||
|
|
a9be598241 | ||
|
|
9a0c269713 | ||
|
|
0c8410fcc3 | ||
|
|
12d7b6fa0c | ||
|
|
274652e10e | ||
|
|
2e9558cbf9 | ||
|
|
13781f242b | ||
|
|
b6469ee186 | ||
|
|
304cc29cf0 | ||
|
|
0d5ee024d1 | ||
|
|
9a88e3656c | ||
|
|
c19535a3f5 | ||
|
|
9af7409e4a | ||
|
|
eca6118023 | ||
|
|
50485d641b | ||
|
|
cd378cb170 | ||
|
|
db7e0976f2 | ||
|
|
ecb7a15baa | ||
|
|
5f225cd625 | ||
|
|
8599ea29f9 | ||
|
|
b1d0cfa77b | ||
|
|
a0a2ee4414 | ||
|
|
60e66fa7be | ||
|
|
45eff43cd0 | ||
|
|
eb588566f2 | ||
|
|
17daa68a35 | ||
|
|
47c87b8478 | ||
|
|
58dafdaedd | ||
|
|
4d2faba9af | ||
|
|
bc4c5644f5 | ||
|
|
950da2b836 | ||
|
|
2459843b92 | ||
|
|
58033251fd | ||
|
|
8df2dd2ba8 | ||
|
|
591a3bb19d | ||
|
|
679c71650f | ||
|
|
5c7996da5b | ||
|
|
9021cf579a | ||
|
|
7afe2c5e2d | ||
|
|
8143f5a618 | ||
|
|
c211357e70 | ||
|
|
3eb09ab984 | ||
|
|
670870e211 | ||
|
|
74ca011704 | ||
|
|
83c5b6286d | ||
|
|
d7015c7f65 | ||
|
|
4ca71d81cf | ||
|
|
ed69b5cc71 | ||
|
|
f9d5a85f05 | ||
|
|
1f3ea299fa | ||
|
|
b2ef0cb14c | ||
|
|
59c4dc735a | ||
|
|
ce7d2e7618 | ||
|
|
4df45ac51a | ||
|
|
8573b95a2d | ||
|
|
94fff5c923 | ||
|
|
56e32888ea | ||
|
|
b186b6327a | ||
|
|
e99fc43ab2 | ||
|
|
cf515c4ff8 | ||
|
|
037f52a55b | ||
|
|
b714db7a95 | ||
|
|
aba4346a86 | ||
|
|
5686d9a3bb | ||
|
|
49e9a309c3 | ||
|
|
788d87774f | ||
|
|
7ccc2dd5ed | ||
|
|
7862182d6f | ||
|
|
b4a9c14d4e | ||
|
|
473dd86f48 | ||
|
|
6e1c249ecd | ||
|
|
dc7a42062e | ||
|
|
dd157129a6 | ||
|
|
d3f04c793e | ||
|
|
ef7e3cc39a | ||
|
|
e6116d96ab | ||
|
|
5e2ad5bb8d | ||
|
|
a7a91441aa | ||
|
|
a2a8ddb779 | ||
|
|
1ad9d18257 | ||
|
|
e58c495f69 | ||
|
|
676a2cc865 | ||
|
|
c6f72953c9 | ||
|
|
41352e866d | ||
|
|
34a067647c | ||
|
|
db3035c29b | ||
|
|
01f8eef7a2 | ||
|
|
e6d1d0c4de | ||
|
|
d6fe38a356 | ||
|
|
1478c72124 | ||
|
|
8e8da23711 | ||
|
|
62dec72394 | ||
|
|
c2e4e1a8a7 | ||
|
|
6a98d168b7 | ||
|
|
8ce8bef249 | ||
|
|
2b216ab5d1 | ||
|
|
af105894d7 | ||
|
|
e5d7d493b9 | ||
|
|
e0bd3735f1 | ||
|
|
81d731d355 | ||
|
|
2eddca3d9f | ||
|
|
6a6e435855 | ||
|
|
7fb6d1ec6a | ||
|
|
6690aecc6c | ||
|
|
137539cf48 | ||
|
|
4a7945f8c1 | ||
|
|
8b9c0b933c | ||
|
|
8983644854 | ||
|
|
39c5d0597d | ||
|
|
ab71d50b3a | ||
|
|
36ce8f0010 | ||
|
|
c6cb1601f7 | ||
|
|
be0b2926b3 | ||
|
|
f8a6e23fa7 | ||
|
|
1e353b2773 | ||
|
|
9537db1a4a | ||
|
|
e7e84ec376 | ||
|
|
6a2d92bc51 | ||
|
|
855d89bef0 | ||
|
|
36843d97cb | ||
|
|
c5437bb222 | ||
|
|
d428bcd50e | ||
|
|
f82cde11a9 | ||
|
|
dc46a740a3 | ||
|
|
93e84a2676 | ||
|
|
5a4c097aac | ||
|
|
5c6af59fcd | ||
|
|
72fd8c970a | ||
|
|
d1d53ea979 | ||
|
|
04dba10b9a | ||
|
|
8486a0da2b | ||
|
|
b2b29ff5c5 | ||
|
|
6c57b275db | ||
|
|
7cc6f37e69 | ||
|
|
0f05655ee6 | ||
|
|
6b932e59c3 | ||
|
|
9a8e66cfca | ||
|
|
66633de1a9 | ||
|
|
bc04ed3ece | ||
|
|
9205ff8001 | ||
|
|
367ae728fb | ||
|
|
335456d008 | ||
|
|
eade411422 | ||
|
|
cca6edfc5c | ||
|
|
42915fc21c | ||
|
|
f1b484ee87 | ||
|
|
6c3708d337 | ||
|
|
91a7aa8611 | ||
|
|
db7494494c | ||
|
|
ca44bafff2 | ||
|
|
01189e144c | ||
|
|
3fe12f0a49 | ||
|
|
e4acd63991 | ||
|
|
3ce23aa726 | ||
|
|
205117bed4 | ||
|
|
9c7da6cec3 | ||
|
|
1088b4b00f | ||
|
|
5811cb9e73 | ||
|
|
0ec339e040 | ||
|
|
7226e5fb98 | ||
|
|
bc9c82cb9f | ||
|
|
f605581c7d | ||
|
|
87a76af398 | ||
|
|
70e1b81ad3 | ||
|
|
e145978e73 | ||
|
|
a6be969403 | ||
|
|
184f641730 | ||
|
|
7dc0827eaa | ||
|
|
278fd031b0 | ||
|
|
7013372867 | ||
|
|
881178db01 | ||
|
|
1845a4a5a9 | ||
|
|
bc508802e5 | ||
|
|
0a4d3a2944 | ||
|
|
5596054445 | ||
|
|
68f7dc9cb3 | ||
|
|
9c3af112ca | ||
|
|
eaf8a50483 | ||
|
|
6c70627478 | ||
|
|
dc2bf8c526 | ||
|
|
b063b32642 | ||
|
|
7bee39fd81 | ||
|
|
2f6b0ca9d7 | ||
|
|
2662840064 | ||
|
|
1a08edd94e | ||
|
|
59c8eda18c | ||
|
|
0803e317e1 | ||
|
|
1709fa9248 | ||
|
|
3c4bf80ec7 | ||
|
|
dd3650fc8f | ||
|
|
4ffd4bb34f | ||
|
|
d6ef9c8893 | ||
|
|
21f00362b0 | ||
|
|
f3bf583285 | ||
|
|
a1d14ea5b8 | ||
|
|
3b2d2e4b61 | ||
|
|
03b16d7a67 | ||
|
|
e1ec264b26 | ||
|
|
182e28f1ae | ||
|
|
5977a02e8b | ||
|
|
ab16d34012 | ||
|
|
c4a13dd2b6 | ||
|
|
7c2dfda88d | ||
|
|
1dbb7c799d | ||
|
|
d9f25f8f58 | ||
|
|
b73f0930cc | ||
|
|
3766bff734 | ||
|
|
304924a969 | ||
|
|
a0c4229abe | ||
|
|
eea0b05ece | ||
|
|
a27d39139b | ||
|
|
903479aeca | ||
|
|
d8713bb2e8 | ||
|
|
4a6c696074 | ||
|
|
a368227237 | ||
|
|
5a17b81a09 | ||
|
|
e1be38f90d | ||
|
|
80cf1159bb | ||
|
|
9fb65cbf7b | ||
|
|
693abf3173 | ||
|
|
e755c47d5a | ||
|
|
3d65d55b5a | ||
|
|
6505c98461 | ||
|
|
5af8cec6dc | ||
|
|
ebff66649e | ||
|
|
07aaa91c9b | ||
|
|
a107b12d2a | ||
|
|
a12b6d7dd6 | ||
|
|
2adbe8bd7f | ||
|
|
04652a5090 | ||
|
|
d68c38902a | ||
|
|
cd14416bfd | ||
|
|
9190297d5e | ||
|
|
ad5242ea0b | ||
|
|
5132a1eb6f | ||
|
|
3bb2634d2f | ||
|
|
e475d7e7ab | ||
|
|
cf00a067ca | ||
|
|
f8c1822033 | ||
|
|
7d4b12446a | ||
|
|
96a4488732 | ||
|
|
3dd6b29905 | ||
|
|
91670abdca | ||
|
|
d544d8e2eb | ||
|
|
3e62657575 | ||
|
|
c371a3a26b | ||
|
|
cfa81b49d1 | ||
|
|
6e50bc0d78 | ||
|
|
6d58fcb8c0 | ||
|
|
5eb95fd641 | ||
|
|
cd7c58ff6a | ||
|
|
a86262520a | ||
|
|
60892c7b51 | ||
|
|
0dd0224f2d | ||
|
|
dcd29296e9 | ||
|
|
45051f4d43 | ||
|
|
7c3af21ebe | ||
|
|
293061b8b7 | ||
|
|
a49f77135a | ||
|
|
1eaf6e2db7 | ||
|
|
b2683fdb11 | ||
|
|
53cfd2dd9b | ||
|
|
ec2327fddd | ||
|
|
18f4064003 | ||
|
|
990ad81419 | ||
|
|
d7cdabe8e2 | ||
|
|
269bb008fc | ||
|
|
a987f8e67d | ||
|
|
0aa40a9c21 | ||
|
|
629b51ebf1 | ||
|
|
39dbc65104 | ||
|
|
0700d14065 | ||
|
|
53e1764a8a | ||
|
|
fda6e7f8de | ||
|
|
6f994715d6 | ||
|
|
8dad534464 | ||
|
|
335a253323 | ||
|
|
09483f422e | ||
|
|
4692f496da | ||
|
|
26b07fbdff | ||
|
|
656549dd44 | ||
|
|
ff3e7d4025 | ||
|
|
f939adbedb | ||
|
|
ac9a52886d | ||
|
|
273aeeee73 | ||
|
|
33c91398bf | ||
|
|
087ce15ccd | ||
|
|
92703939ee | ||
|
|
d6ef0c47a5 | ||
|
|
fd1eb7559b | ||
|
|
c562a491ca | ||
|
|
964e7c303c | ||
|
|
1251684440 | ||
|
|
2ecd1fac63 | ||
|
|
46302a25d2 | ||
|
|
d5638cb241 | ||
|
|
e9f35e7b15 | ||
|
|
fab5db0ec8 | ||
|
|
4c8d3a70ea | ||
|
|
c10ca74b5b | ||
|
|
8d97b78da7 | ||
|
|
d509e32c6f | ||
|
|
61585251f5 |
10
.gitignore
vendored
10
.gitignore
vendored
@@ -2,3 +2,13 @@ HEAD
|
|||||||
src
|
src
|
||||||
v*
|
v*
|
||||||
alias
|
alias
|
||||||
|
|
||||||
|
# For testing
|
||||||
|
test/bak
|
||||||
|
.urchin.log
|
||||||
|
.urchin_stdout
|
||||||
|
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
|
current
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
src
|
src
|
||||||
v*
|
v*
|
||||||
alias
|
alias
|
||||||
|
|
||||||
|
|||||||
29
.travis.yml
Normal file
29
.travis.yml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
language: c # defaults to ruby
|
||||||
|
install:
|
||||||
|
- sudo apt-get install ksh zsh -y
|
||||||
|
- '[ -z "$WITHOUT_CURL" ] || sudo apt-get remove curl -y'
|
||||||
|
before_script:
|
||||||
|
- '[ -n "$WITHOUT_CURL" ] || curl -o /tmp/urchin https://raw.githubusercontent.com/scraperwiki/urchin/master/urchin'
|
||||||
|
- '[ -z "$WITHOUT_CURL" ] || wget -O /tmp/urchin https://raw.githubusercontent.com/scraperwiki/urchin/master/urchin'
|
||||||
|
- chmod +x /tmp/urchin
|
||||||
|
script:
|
||||||
|
- NVM_DIR=$TRAVIS_BUILD_DIR make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin $SHELL
|
||||||
|
env:
|
||||||
|
- SHELL=sh TEST_SUITE=fast
|
||||||
|
- SHELL=sh TEST_SUITE=fast WITHOUT_CURL=1
|
||||||
|
- SHELL=dash TEST_SUITE=fast
|
||||||
|
- SHELL=dash TEST_SUITE=fast WITHOUT_CURL=1
|
||||||
|
- SHELL=bash TEST_SUITE=fast
|
||||||
|
- SHELL=bash TEST_SUITE=fast WITHOUT_CURL=1
|
||||||
|
- SHELL=zsh TEST_SUITE=fast
|
||||||
|
- SHELL=zsh TEST_SUITE=fast WITHOUT_CURL=1
|
||||||
|
- SHELL=ksh TEST_SUITE=fast
|
||||||
|
- SHELL=ksh TEST_SUITE=fast WITHOUT_CURL=1
|
||||||
|
- SHELL=sh TEST_SUITE=slow
|
||||||
|
- SHELL=sh TEST_SUITE=slow WITHOUT_CURL=1
|
||||||
|
- SHELL=dash TEST_SUITE=slow
|
||||||
|
- SHELL=dash TEST_SUITE=slow WITHOUT_CURL=1
|
||||||
|
- SHELL=bash TEST_SUITE=slow
|
||||||
|
- SHELL=bash TEST_SUITE=slow WITHOUT_CURL=1
|
||||||
|
- SHELL=zsh TEST_SUITE=slow
|
||||||
|
- SHELL=zsh TEST_SUITE=slow WITHOUT_CURL=1
|
||||||
15
CONTRIBUTING.md
Normal file
15
CONTRIBUTING.md
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
Thanks for contributing to `nvm`!
|
||||||
|
|
||||||
|
We love pull requests, they're our favorite.
|
||||||
|
|
||||||
|
However, before submitting, please review the following:
|
||||||
|
|
||||||
|
- Please include tests. Changes with tests will be merged very quickly.
|
||||||
|
- Please manually confirm that your changes work in `bash`, `sh`/`dash`, `ksh`, and `zsh`. Fast tests do run in these shells, but it's nice to manually verify also.
|
||||||
|
- Please maintain consistent whitespace - 2-space indentation, trailing newlines in all files, etc.
|
||||||
|
- Any time you make a change to your PR, please rebase freshly on top of master. Nobody likes merge commits.
|
||||||
|
|
||||||
|
Even if you don't have all of these items covered, please still feel free to submit a PR! Someone else may be inspired and volunteer to complete it for you.
|
||||||
|
|
||||||
|
Thanks again!
|
||||||
|
|
||||||
21
LICENSE.md
Normal file
21
LICENSE.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2010-2014 Tim Caswell
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
26
Makefile
Normal file
26
Makefile
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
URCHIN=`which urchin`
|
||||||
|
SHELLS=sh bash dash ksh zsh
|
||||||
|
TEST_SUITE=fast
|
||||||
|
|
||||||
|
.PHONY: $(SHELLS) test verify-tag release
|
||||||
|
|
||||||
|
$(SHELLS):
|
||||||
|
@printf '\n\033[0;34m%s\033[0m\n' "Running tests in $@"
|
||||||
|
@$@ $(URCHIN) -f test/$(TEST_SUITE)
|
||||||
|
|
||||||
|
test: $(SHELLS)
|
||||||
|
@$(URCHIN) -f test/slow
|
||||||
|
|
||||||
|
default: test
|
||||||
|
|
||||||
|
verify-tag:
|
||||||
|
ifndef TAG
|
||||||
|
$(error TAG is undefined)
|
||||||
|
endif
|
||||||
|
|
||||||
|
release: verify-tag
|
||||||
|
@ OLD_TAG=`git describe --abbrev=0 --tags` && \
|
||||||
|
replace "$${OLD_TAG/v/}" "$(TAG)" -- nvm.sh install.sh README.markdown package.json && \
|
||||||
|
git commit -m "v$(TAG)" nvm.sh install.sh README.markdown package.json && \
|
||||||
|
git tag "v$(TAG)"
|
||||||
|
|
||||||
158
README.markdown
158
README.markdown
@@ -1,41 +1,175 @@
|
|||||||
# Node Version Manager
|
# Node Version Manager [][3]
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
First you'll need to make sure your system has a c++ compiler. For OSX, XCode will work, for Ubuntu, the build-essential and libssl-dev packages work.
|
First you'll need to make sure your system has a c++ compiler. For OSX, XCode will work, for Ubuntu, the build-essential and libssl-dev packages work.
|
||||||
|
|
||||||
To install create a folder somewhere in your filesystem with the "`nvm.sh`" file inside it. I put mine in a folder called "`.nvm`".
|
### Install script
|
||||||
|
|
||||||
|
To install you could use the [install script][2] using cURL:
|
||||||
|
|
||||||
|
curl https://raw.githubusercontent.com/creationix/nvm/v0.15.0/install.sh | bash
|
||||||
|
|
||||||
|
or Wget:
|
||||||
|
|
||||||
|
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.15.0/install.sh | bash
|
||||||
|
|
||||||
|
<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc` or `~/.profile`).</sub>
|
||||||
|
|
||||||
|
You can customize the install source, directory and profile using the `NVM_SOURCE`, `NVM_DIR` and `PROFILE` variables. Eg: `curl ... | NVM_DIR=/usr/local/nvm bash` for a global install.
|
||||||
|
|
||||||
|
<sub>*NB. The installer can use Git, curl, or wget to download NVM, whatever is available.*</sub>
|
||||||
|
|
||||||
|
### Manual install
|
||||||
|
|
||||||
|
For manual install create a folder somewhere in your filesystem with the `nvm.sh` file inside it. I put mine in a folder called `nvm`.
|
||||||
|
|
||||||
Or if you have `git` installed, then just clone it:
|
Or if you have `git` installed, then just clone it:
|
||||||
|
|
||||||
git clone git://github.com/creationix/nvm.git ~/.nvm
|
git clone https://github.com/creationix/nvm.git ~/.nvm
|
||||||
|
|
||||||
To activate nvm, you need to source it from your bash shell
|
To activate nvm, you need to source it from your shell:
|
||||||
|
|
||||||
. ~/.nvm/nvm.sh
|
source ~/.nvm/nvm.sh
|
||||||
|
|
||||||
I always add this line to my ~/.bashrc or ~/.profile file to have it automatically sources upon login.
|
I always add this line to my `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to have it automatically sourced upon login.
|
||||||
Often I also put in a line to use a specific version of node.
|
Often I also put in a line to use a specific version of node.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
To download, compile, and install the v0.4.1 release of node, do this:
|
You can create an `.nvmrc` file containing version number in the project root directory (or any parent directory).
|
||||||
|
`nvm use`, `nvm install`, `nvm exec`, and `nvm run` will all respect an `.nvmrc` file.
|
||||||
|
|
||||||
nvm install v0.4.1
|
To download, compile, and install the latest v0.10.x release of node, do this:
|
||||||
|
|
||||||
|
nvm install 0.10
|
||||||
|
|
||||||
And then in any new shell just use the installed version:
|
And then in any new shell just use the installed version:
|
||||||
|
|
||||||
nvm use v0.4.1
|
nvm use 0.10
|
||||||
|
|
||||||
If you want to see what versions are available:
|
Or you can just run it:
|
||||||
|
|
||||||
|
nvm run 0.10 --version
|
||||||
|
|
||||||
|
Or, you can run any arbitrary command in a subshell with the desired version of node:
|
||||||
|
|
||||||
|
nvm exec 0.10 node --version
|
||||||
|
|
||||||
|
If you want to see what versions are installed:
|
||||||
|
|
||||||
nvm ls
|
nvm ls
|
||||||
|
|
||||||
|
If you want to see what versions are available to install:
|
||||||
|
|
||||||
|
nvm ls-remote
|
||||||
|
|
||||||
To restore your PATH, you can deactivate it.
|
To restore your PATH, you can deactivate it.
|
||||||
|
|
||||||
nvm deactivate
|
nvm deactivate
|
||||||
|
|
||||||
To set a default Node version to be used in any new shell, use the alias 'default':
|
To set a default Node version to be used in any new shell, use the alias 'default':
|
||||||
|
|
||||||
nvm alias default v0.4.1
|
nvm alias default 0.10
|
||||||
|
|
||||||
|
To use a mirror of the node binaries, set `$NVM_NODEJS_ORG_MIRROR`:
|
||||||
|
|
||||||
|
export NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist
|
||||||
|
nvm install 0.10
|
||||||
|
|
||||||
|
NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist nvm install 0.10
|
||||||
|
|
||||||
|
`nvm use` will, by defaut, create a "current" symlink. Set `$NVM_SYMLINK_CURRENT` to any value other than "true" to disable this behavior.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
nvm is released under the MIT license.
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (C) 2010-2014 Tim Caswell
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
## Running tests
|
||||||
|
Tests are written in [Urchin]. Install Urchin (and other dependencies) like so:
|
||||||
|
|
||||||
|
npm install
|
||||||
|
|
||||||
|
There are slow tests and fast tests. The slow tests do things like install node
|
||||||
|
and check that the right versions are used. The fast tests fake this to test
|
||||||
|
things like aliases and uninstalling. From the root of the nvm git repository,
|
||||||
|
run the fast tests like this.
|
||||||
|
|
||||||
|
npm run test/fast
|
||||||
|
|
||||||
|
Run the slow tests like this.
|
||||||
|
|
||||||
|
npm run test/slow
|
||||||
|
|
||||||
|
Run all of the tests like this
|
||||||
|
|
||||||
|
npm test
|
||||||
|
|
||||||
|
Nota bene: Avoid running nvm while the tests are running.
|
||||||
|
|
||||||
|
## Bash completion
|
||||||
|
|
||||||
|
To activate, you need to source `bash_completion`:
|
||||||
|
|
||||||
|
[[ -r $NVM_DIR/bash_completion ]] && . $NVM_DIR/bash_completion
|
||||||
|
|
||||||
|
Put the above sourcing line just below the sourcing line for NVM in your profile (`.bashrc`, `.bash_profile`).
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
|
||||||
|
nvm
|
||||||
|
|
||||||
|
$ nvm [tab][tab]
|
||||||
|
alias copy-packages help list run uninstall version
|
||||||
|
clear-cache deactivate install ls unalias use
|
||||||
|
|
||||||
|
nvm alias
|
||||||
|
|
||||||
|
$ nvm alias [tab][tab]
|
||||||
|
default
|
||||||
|
|
||||||
|
$ nvm alias my_alias [tab][tab]
|
||||||
|
v0.6.21 v0.8.26 v0.10.28
|
||||||
|
|
||||||
|
nvm use
|
||||||
|
|
||||||
|
$ nvm use [tab][tab]
|
||||||
|
my_alias default v0.6.21 v0.8.26 v0.10.28
|
||||||
|
|
||||||
|
nvm uninstall
|
||||||
|
|
||||||
|
$ nvm uninstall [tab][tab]
|
||||||
|
my_alias default v0.6.21 v0.8.26 v0.10.28
|
||||||
|
|
||||||
|
## Problems
|
||||||
|
|
||||||
|
If you try to install a node version and the installation fails, be sure to delete the node downloads from src (~/.nvm/src/) or you might get an error when trying to reinstall them again or you might get an error like the following:
|
||||||
|
|
||||||
|
curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume.
|
||||||
|
|
||||||
|
Where's my 'sudo node'? Checkout this link:
|
||||||
|
|
||||||
|
https://github.com/creationix/nvm/issues/43
|
||||||
|
|
||||||
|
on Arch Linux and other systems using python3 by default, before running *install* you need to
|
||||||
|
|
||||||
|
export PYTHON=python2
|
||||||
|
|
||||||
|
After the v0.8.6 release of node, nvm tries to install from binary packages. But in some systems, the official binary packages don't work due to incompatibility of shared libs. In such cases, use `-s` option to force install from source:
|
||||||
|
|
||||||
|
nvm install -s 0.8.6
|
||||||
|
|
||||||
|
[1]: https://github.com/creationix/nvm.git
|
||||||
|
[2]: https://github.com/creationix/nvm/blob/v0.15.0/install.sh
|
||||||
|
[3]: https://travis-ci.org/creationix/nvm
|
||||||
|
[Urchin]: https://github.com/scraperwiki/urchin
|
||||||
|
|
||||||
|
|||||||
90
bash_completion
Normal file
90
bash_completion
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# bash completion for Node Version Manager (NVM)
|
||||||
|
|
||||||
|
__nvm_generate_completion()
|
||||||
|
{
|
||||||
|
declare current_word
|
||||||
|
current_word="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
COMPREPLY=($(compgen -W "$1" -- "$current_word"))
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
__nvm_commands ()
|
||||||
|
{
|
||||||
|
declare current_word
|
||||||
|
declare command
|
||||||
|
|
||||||
|
current_word="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
|
||||||
|
COMMANDS='\
|
||||||
|
help install uninstall use run\
|
||||||
|
ls ls-remote list list-remote deactivate\
|
||||||
|
alias unalias copy-packages clear-cache version'
|
||||||
|
|
||||||
|
if [ ${#COMP_WORDS[@]} == 4 ]; then
|
||||||
|
|
||||||
|
command="${COMP_WORDS[COMP_CWORD-2]}"
|
||||||
|
case "${command}" in
|
||||||
|
alias) __nvm_installed_nodes ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
case "${current_word}" in
|
||||||
|
-*) __nvm_options ;;
|
||||||
|
*) __nvm_generate_completion "$COMMANDS" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
__nvm_options ()
|
||||||
|
{
|
||||||
|
OPTIONS=''
|
||||||
|
__nvm_generate_completion "$OPTIONS"
|
||||||
|
}
|
||||||
|
|
||||||
|
__nvm_installed_nodes ()
|
||||||
|
{
|
||||||
|
__nvm_generate_completion "$(nvm_ls) $(__nvm_aliases)"
|
||||||
|
}
|
||||||
|
|
||||||
|
__nvm_aliases ()
|
||||||
|
{
|
||||||
|
declare aliases
|
||||||
|
aliases=""
|
||||||
|
if [ -d $NVM_DIR/alias ]; then
|
||||||
|
aliases="`cd $NVM_DIR/alias && ls`"
|
||||||
|
fi
|
||||||
|
echo "${aliases}"
|
||||||
|
}
|
||||||
|
|
||||||
|
__nvm_alias ()
|
||||||
|
{
|
||||||
|
__nvm_generate_completion "$(__nvm_aliases)"
|
||||||
|
}
|
||||||
|
|
||||||
|
__nvm ()
|
||||||
|
{
|
||||||
|
declare previous_word
|
||||||
|
previous_word="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
|
||||||
|
case "$previous_word" in
|
||||||
|
use|run|ls|list|uninstall) __nvm_installed_nodes ;;
|
||||||
|
alias|unalias) __nvm_alias ;;
|
||||||
|
*) __nvm_commands ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# complete is a bash builtin, but recent versions of ZSH come with a function
|
||||||
|
# called bashcompinit that will create a complete in ZSH. If the user is in
|
||||||
|
# ZSH, load and run bashcompinit before calling the complete function.
|
||||||
|
if [[ -n ${ZSH_VERSION-} ]]; then
|
||||||
|
autoload -U +X bashcompinit && bashcompinit
|
||||||
|
fi
|
||||||
|
|
||||||
|
complete -o default -o nospace -F __nvm nvm
|
||||||
|
|
||||||
139
install.sh
139
install.sh
@@ -1,22 +1,131 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
dir=$npm_config_root/.npm/$npm_package_name/$npm_package_version/package
|
set -e
|
||||||
|
|
||||||
# add lines to the bashrc.
|
nvm_has() {
|
||||||
has=$(cat ~/.bashrc | egrep "^# ADDED BY npm FOR NVM$" || true)
|
type "$1" > /dev/null 2>&1
|
||||||
if [ "x$has" != "x" ]; then
|
return $?
|
||||||
exit 0
|
}
|
||||||
|
|
||||||
|
if [ -z "$NVM_DIR" ]; then
|
||||||
|
NVM_DIR="$HOME/.nvm"
|
||||||
fi
|
fi
|
||||||
cat <<NVM_CODE >>~/.bashrc
|
|
||||||
# ADDED BY npm FOR NVM
|
|
||||||
. $dir/nvm.sh
|
|
||||||
# END ADDED BY npm FOR NVM
|
|
||||||
NVM_CODE
|
|
||||||
|
|
||||||
cat <<NVM_HOWTO
|
nvm_download() {
|
||||||
|
if nvm_has "curl"; then
|
||||||
|
curl $*
|
||||||
|
elif nvm_has "wget"; then
|
||||||
|
# Emulate curl with wget
|
||||||
|
ARGS=$(echo "$*" | sed -e 's/--progress-bar /--progress=bar /' \
|
||||||
|
-e 's/-L //' \
|
||||||
|
-e 's/-I /--server-response /' \
|
||||||
|
-e 's/-s /-q /' \
|
||||||
|
-e 's/-o /-O /' \
|
||||||
|
-e 's/-C - /-c /')
|
||||||
|
wget $ARGS
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
To use nvm, source your .bashrc file like this:
|
install_nvm_from_git() {
|
||||||
. ~/.bashrc
|
if [ -z "$NVM_SOURCE" ]; then
|
||||||
or log out and back into your terminal.
|
NVM_SOURCE="https://github.com/creationix/nvm.git"
|
||||||
|
fi
|
||||||
|
|
||||||
NVM_HOWTO
|
if [ -d "$NVM_DIR/.git" ]; then
|
||||||
|
echo "=> nvm is already installed in $NVM_DIR, trying to update"
|
||||||
|
printf "\r=> "
|
||||||
|
cd "$NVM_DIR" && (git fetch 2> /dev/null || {
|
||||||
|
echo >&2 "Failed to update nvm, run 'git fetch' in $NVM_DIR yourself." && exit 1
|
||||||
|
})
|
||||||
|
else
|
||||||
|
# Cloning to $NVM_DIR
|
||||||
|
echo "=> Downloading nvm from git to '$NVM_DIR'"
|
||||||
|
printf "\r=> "
|
||||||
|
mkdir -p "$NVM_DIR"
|
||||||
|
git clone "$NVM_SOURCE" "$NVM_DIR"
|
||||||
|
fi
|
||||||
|
cd $NVM_DIR && git checkout v0.15.0 && git branch -D master || true
|
||||||
|
}
|
||||||
|
|
||||||
|
install_nvm_as_script() {
|
||||||
|
if [ -z "$NVM_SOURCE" ]; then
|
||||||
|
NVM_SOURCE="https://raw.githubusercontent.com/creationix/nvm/v0.15.0/nvm.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Downloading to $NVM_DIR
|
||||||
|
mkdir -p "$NVM_DIR"
|
||||||
|
if [ -d "$NVM_DIR/nvm.sh" ]; then
|
||||||
|
echo "=> nvm is already installed in $NVM_DIR, trying to update"
|
||||||
|
else
|
||||||
|
echo "=> Downloading nvm as script to '$NVM_DIR'"
|
||||||
|
fi
|
||||||
|
nvm_download -s "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || {
|
||||||
|
echo >&2 "Failed to download '$NVM_SOURCE'.."
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "$METHOD" ]; then
|
||||||
|
# Autodetect install method
|
||||||
|
if nvm_has "git"; then
|
||||||
|
install_nvm_from_git
|
||||||
|
elif nvm_has "nvm_download"; then
|
||||||
|
install_nvm_as_script
|
||||||
|
else
|
||||||
|
echo >&2 "You need git, curl, or wget to install nvm"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ "$METHOD" = "git" ]; then
|
||||||
|
if ! nvm_has "git"; then
|
||||||
|
echo >&2 "You need git to install nvm"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
install_nvm_from_git
|
||||||
|
fi
|
||||||
|
if [ "$METHOD" = "script" ]; then
|
||||||
|
if ! nvm_has "nvm_download"; then
|
||||||
|
echo >&2 "You need curl or wget to install nvm"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
install_nvm_as_script
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Detect profile file if not specified as environment variable (eg: PROFILE=~/.myprofile).
|
||||||
|
if [ -z "$PROFILE" ]; then
|
||||||
|
if [ -f "$HOME/.bash_profile" ]; then
|
||||||
|
PROFILE="$HOME/.bash_profile"
|
||||||
|
elif [ -f "$HOME/.zshrc" ]; then
|
||||||
|
PROFILE="$HOME/.zshrc"
|
||||||
|
elif [ -f "$HOME/.profile" ]; then
|
||||||
|
PROFILE="$HOME/.profile"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
SOURCE_STR="\nexport NVM_DIR=\"$NVM_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\" # This loads nvm"
|
||||||
|
|
||||||
|
if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then
|
||||||
|
if [ -z "$PROFILE" ]; then
|
||||||
|
echo "=> Profile not found. Tried ~/.bash_profile, ~/.zshrc, and ~/.profile."
|
||||||
|
echo "=> Create one of them and run this script again"
|
||||||
|
else
|
||||||
|
echo "=> Profile $PROFILE not found"
|
||||||
|
echo "=> Create it (touch $PROFILE) and run this script again"
|
||||||
|
fi
|
||||||
|
echo " OR"
|
||||||
|
echo "=> Append the following lines to the correct file yourself:"
|
||||||
|
printf "$SOURCE_STR"
|
||||||
|
echo
|
||||||
|
else
|
||||||
|
if ! grep -qc 'nvm.sh' "$PROFILE"; then
|
||||||
|
echo "=> Appending source string to $PROFILE"
|
||||||
|
printf "$SOURCE_STR\n" >> "$PROFILE"
|
||||||
|
else
|
||||||
|
echo "=> Source string already in $PROFILE"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "=> Close and reopen your terminal to start using nvm"
|
||||||
|
|||||||
14
nvm-exec
Executable file
14
nvm-exec
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
source "$DIR/nvm.sh"
|
||||||
|
|
||||||
|
if [ -n "$NODE_VERSION" ]; then
|
||||||
|
nvm use $NODE_VERSION > /dev/null || (echo "NODE_VERSION not set" >&2 && exit 127)
|
||||||
|
else
|
||||||
|
nvm use > /dev/null || (echo "No .nvmrc file found" >&2 && exit 127)
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec $@
|
||||||
|
|
||||||
878
nvm.sh
878
nvm.sh
@@ -1,79 +1,358 @@
|
|||||||
# Node Version Manager
|
# Node Version Manager
|
||||||
# Implemented as a bash function
|
# Implemented as a POSIX-compliant function
|
||||||
|
# Should work on sh, dash, bash, ksh, zsh
|
||||||
# To use source this file from your bash profile
|
# To use source this file from your bash profile
|
||||||
#
|
#
|
||||||
# Implemented by Tim Caswell <tim@creationix.com>
|
# Implemented by Tim Caswell <tim@creationix.com>
|
||||||
# with much bash help from Matthew Ranney
|
# with much bash help from Matthew Ranney
|
||||||
|
|
||||||
# Auto detect the NVM_DIR
|
NVM_SCRIPT_SOURCE="$_"
|
||||||
if [ ! -d "$NVM_DIR" ]; then
|
|
||||||
export NVM_DIR=$(cd $(dirname ${BASH_SOURCE[0]:-$0}); pwd)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Emulate curl with wget, if necessary
|
nvm_has() {
|
||||||
if [ ! `which curl` ]; then
|
type "$1" > /dev/null 2>&1
|
||||||
if [ `which wget` ]; then
|
|
||||||
curl() {
|
|
||||||
ARGS="$* "
|
|
||||||
ARGS=${ARGS/-s /-q }
|
|
||||||
ARGS=${ARGS/-\# /}
|
|
||||||
ARGS=${ARGS/-C - /-c }
|
|
||||||
ARGS=${ARGS/-o /-O }
|
|
||||||
|
|
||||||
wget $ARGS
|
|
||||||
}
|
|
||||||
else
|
|
||||||
NOCURL='nocurl'
|
|
||||||
curl() { echo 'Need curl or wget to proceed.' >&2; }
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Expand a version using the version cache
|
|
||||||
nvm_version()
|
|
||||||
{
|
|
||||||
PATTERN=$1
|
|
||||||
VERSION=''
|
|
||||||
if [ -f "$NVM_DIR/alias/$PATTERN" ]; then
|
|
||||||
nvm_version `cat $NVM_DIR/alias/$PATTERN`
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
# If it looks like an explicit version, don't do anything funny
|
|
||||||
if [[ "$PATTERN" == v*.*.* ]]; then
|
|
||||||
VERSION="$PATTERN"
|
|
||||||
fi
|
|
||||||
# The default version is the current one
|
|
||||||
if [ ! "$PATTERN" -o "$PATTERN" = 'current' ]; then
|
|
||||||
VERSION=`node -v 2>/dev/null`
|
|
||||||
fi
|
|
||||||
if [ "$PATTERN" = 'stable' ]; then
|
|
||||||
PATTERN='*.*[02468].'
|
|
||||||
fi
|
|
||||||
if [ "$PATTERN" = 'latest' ]; then
|
|
||||||
PATTERN='*.*.'
|
|
||||||
fi
|
|
||||||
if [ "$PATTERN" = 'all' ]; then
|
|
||||||
(cd $NVM_DIR; ls -dG v* 2>/dev/null || echo "N/A")
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
if [ ! "$VERSION" ]; then
|
|
||||||
VERSION=`(cd $NVM_DIR; ls -d v${PATTERN}* 2>/dev/null) | sort -t. -k 2,1n -k 2,2n -k 3,3n | tail -n1`
|
|
||||||
fi
|
|
||||||
if [ ! "$VERSION" ]; then
|
|
||||||
echo "N/A"
|
|
||||||
return 13
|
|
||||||
elif [ -e "$NVM_DIR/$VERSION" ]; then
|
|
||||||
(cd $NVM_DIR; ls -dG "$VERSION")
|
|
||||||
else
|
|
||||||
echo "$VERSION"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm()
|
nvm_download() {
|
||||||
{
|
if nvm_has "curl"; then
|
||||||
|
curl $*
|
||||||
|
elif nvm_has "wget"; then
|
||||||
|
# Emulate curl with wget
|
||||||
|
ARGS=$(echo "$*" | sed -e 's/--progress-bar /--progress=bar /' \
|
||||||
|
-e 's/-L //' \
|
||||||
|
-e 's/-I /--server-response /' \
|
||||||
|
-e 's/-s /-q /' \
|
||||||
|
-e 's/-o /-O /' \
|
||||||
|
-e 's/-C - /-c /')
|
||||||
|
eval wget $ARGS
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_has_system_node() {
|
||||||
|
[ "$(nvm deactivate 2> /dev/null && command -v node)" != '' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Make zsh glob matching behave same as bash
|
||||||
|
# This fixes the "zsh: no matches found" errors
|
||||||
|
if nvm_has "unsetopt"; then
|
||||||
|
unsetopt nomatch 2>/dev/null
|
||||||
|
NVM_CD_FLAGS="-q"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Auto detect the NVM_DIR when not set
|
||||||
|
if [ -z "$NVM_DIR" ]; then
|
||||||
|
if [ -n "$BASH_SOURCE" ]; then
|
||||||
|
NVM_SCRIPT_SOURCE="${BASH_SOURCE[0]}"
|
||||||
|
fi
|
||||||
|
export NVM_DIR=$(cd $NVM_CD_FLAGS $(dirname "${NVM_SCRIPT_SOURCE:-$0}") > /dev/null && pwd)
|
||||||
|
fi
|
||||||
|
unset NVM_SCRIPT_SOURCE 2> /dev/null
|
||||||
|
|
||||||
|
|
||||||
|
# Setup mirror location if not already set
|
||||||
|
if [ -z "$NVM_NODEJS_ORG_MIRROR" ]; then
|
||||||
|
export NVM_NODEJS_ORG_MIRROR="http://nodejs.org/dist"
|
||||||
|
fi
|
||||||
|
|
||||||
|
nvm_tree_contains_path() {
|
||||||
|
local tree
|
||||||
|
tree="$1"
|
||||||
|
local node_path
|
||||||
|
node_path="$2"
|
||||||
|
|
||||||
|
if [ "@$tree@" = "@@" ] || [ "@$node_path@" = "@@" ]; then
|
||||||
|
>&2 echo "both the tree and the node path are required"
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
local pathdir
|
||||||
|
pathdir=$(dirname "$node_path")
|
||||||
|
while [ "$pathdir" != "" ] && [ "$pathdir" != "." ] && [ "$pathdir" != "/" ] && [ "$pathdir" != "$tree" ]; do
|
||||||
|
pathdir=$(dirname "$pathdir")
|
||||||
|
done
|
||||||
|
[ "$pathdir" = "$tree" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Traverse up in directory tree to find containing folder
|
||||||
|
nvm_find_up() {
|
||||||
|
local path
|
||||||
|
path=$PWD
|
||||||
|
while [ "$path" != "" ] && [ ! -f "$path/$1" ]; do
|
||||||
|
path=${path%/*}
|
||||||
|
done
|
||||||
|
echo "$path"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
nvm_find_nvmrc() {
|
||||||
|
local dir
|
||||||
|
dir="$(nvm_find_up '.nvmrc')"
|
||||||
|
if [ -e "$dir/.nvmrc" ]; then
|
||||||
|
echo "$dir/.nvmrc"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Obtain nvm version from rc file
|
||||||
|
nvm_rc_version() {
|
||||||
|
local NVMRC_PATH
|
||||||
|
NVMRC_PATH="$(nvm_find_nvmrc)"
|
||||||
|
if [ -e "$NVMRC_PATH" ]; then
|
||||||
|
read NVM_RC_VERSION < "$NVMRC_PATH"
|
||||||
|
echo "Found '$NVMRC_PATH' with version <$NVM_RC_VERSION>"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_version_greater() {
|
||||||
|
local LHS
|
||||||
|
LHS=$(echo "$1" | awk -F. '{for (i=1;i<=NF;++i) printf "%010d",$i}')
|
||||||
|
local RHS
|
||||||
|
RHS=$(echo "$2" | awk -F. '{for (i=1;i<=NF;++i) printf "%010d",$i}')
|
||||||
|
[ $LHS -gt $RHS ];
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_version_dir() {
|
||||||
|
local NVM_USE_NEW_DIR
|
||||||
|
NVM_USE_NEW_DIR="$1"
|
||||||
|
if [ -z "$NVM_USE_NEW_DIR" ] || [ "$NVM_USE_NEW_DIR" = "new" ]; then
|
||||||
|
echo "$NVM_DIR/versions"
|
||||||
|
elif [ "$NVM_USE_NEW_DIR" = "old" ]; then
|
||||||
|
echo "$NVM_DIR"
|
||||||
|
else
|
||||||
|
echo "unknown version dir" >&2
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_version_path() {
|
||||||
|
local VERSION
|
||||||
|
VERSION="$1"
|
||||||
|
if [ -z "$VERSION" ]; then
|
||||||
|
echo "version is required" >&2
|
||||||
|
return 3
|
||||||
|
elif nvm_version_greater 0.12.0 "$VERSION"; then
|
||||||
|
echo "$(nvm_version_dir old)/$VERSION"
|
||||||
|
else
|
||||||
|
echo "$(nvm_version_dir new)/$VERSION"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Expand a version using the version cache
|
||||||
|
nvm_version() {
|
||||||
|
local PATTERN
|
||||||
|
PATTERN=$1
|
||||||
|
local VERSION
|
||||||
|
# The default version is the current one
|
||||||
|
if [ -z "$PATTERN" ]; then
|
||||||
|
PATTERN='current'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$PATTERN" = "current" ]; then
|
||||||
|
nvm_ls_current
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
VERSION=`nvm_ls $PATTERN | tail -n1`
|
||||||
|
echo "$VERSION"
|
||||||
|
|
||||||
|
if [ "$VERSION" = 'N/A' ]; then
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_remote_version() {
|
||||||
|
local PATTERN
|
||||||
|
PATTERN=$1
|
||||||
|
local VERSION
|
||||||
|
VERSION=`nvm_ls_remote $PATTERN | tail -n1`
|
||||||
|
echo "$VERSION"
|
||||||
|
|
||||||
|
if [ "$VERSION" = 'N/A' ]; then
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_normalize_version() {
|
||||||
|
echo "$1" | sed -e 's/^v//' | \awk -F. '{ printf("%d%03d%03d\n", $1,$2,$3); }'
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_format_version() {
|
||||||
|
echo "$1" | sed -e 's/^\([0-9]\)/v\1/g'
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_strip_path() {
|
||||||
|
echo "$1" | sed -e "s#$NVM_DIR/[^/]*$2[^:]*:##g" -e "s#:$NVM_DIR/[^/]*$2[^:]*##g" -e "s#$NVM_DIR/[^/]*$2[^:]*##g"
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_prepend_path() {
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "$2"
|
||||||
|
else
|
||||||
|
echo "$2:$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_binary_available() {
|
||||||
|
# binaries started with node 0.8.6
|
||||||
|
local MINIMAL
|
||||||
|
MINIMAL="0.8.6"
|
||||||
|
local VERSION
|
||||||
|
VERSION=$1
|
||||||
|
[ $(nvm_normalize_version $VERSION) -ge $(nvm_normalize_version $MINIMAL) ]
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_ls_current() {
|
||||||
|
local NODE_PATH
|
||||||
|
NODE_PATH="$(which node 2> /dev/null)"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo 'none'
|
||||||
|
elif nvm_tree_contains_path "$NVM_DIR" "$NODE_PATH"; then
|
||||||
|
local VERSION
|
||||||
|
VERSION=`node -v 2>/dev/null`
|
||||||
|
if [ "$VERSION" = "v0.6.21-pre" ]; then
|
||||||
|
echo "v0.6.21"
|
||||||
|
else
|
||||||
|
echo "$VERSION"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo 'system'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_ls() {
|
||||||
|
local PATTERN
|
||||||
|
PATTERN=$1
|
||||||
|
local VERSIONS
|
||||||
|
VERSIONS=''
|
||||||
|
if [ "$PATTERN" = 'current' ]; then
|
||||||
|
nvm_ls_current
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$NVM_DIR/alias/$PATTERN" ]; then
|
||||||
|
nvm_version `cat $NVM_DIR/alias/$PATTERN`
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
# If it looks like an explicit version, don't do anything funny
|
||||||
|
if [ `expr "$PATTERN" : "v[0-9]*\.[0-9]*\.[0-9]*$"` != 0 ]; then
|
||||||
|
if [ -d "$(nvm_version_path "$PATTERN")" ]; then
|
||||||
|
VERSIONS="$PATTERN"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
PATTERN=$(nvm_format_version $PATTERN)
|
||||||
|
if [ `expr "$PATTERN" : "v[0-9]*\.[0-9]*$"` != 0 ]; then
|
||||||
|
PATTERN="$PATTERN."
|
||||||
|
fi
|
||||||
|
if [ -d "$(nvm_version_dir new)" ]; then
|
||||||
|
VERSIONS=`find "$(nvm_version_dir new)/" "$(nvm_version_dir old)/" -maxdepth 1 -type d -name "$PATTERN*" -exec basename '{}' ';' \
|
||||||
|
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | \grep -v '^ *\.' | \grep -e '^v' | \grep -v -e '^versions$'`
|
||||||
|
else
|
||||||
|
VERSIONS=`find "$(nvm_version_dir old)/" -maxdepth 1 -type d -name "$PATTERN*" -exec basename '{}' ';' \
|
||||||
|
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n | \grep -v '^ *\.' | \grep -e '^v'`
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -z "$VERSIONS" ]; then
|
||||||
|
echo "N/A"
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
|
if [ -z "$PATTERN" ] && nvm_has_system_node; then
|
||||||
|
VERSIONS="$VERSIONS$(printf '\n%s' 'system')"
|
||||||
|
fi
|
||||||
|
echo "$VERSIONS"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_ls_remote() {
|
||||||
|
local PATTERN
|
||||||
|
PATTERN=$1
|
||||||
|
local VERSIONS
|
||||||
|
local GREP_OPTIONS
|
||||||
|
GREP_OPTIONS=''
|
||||||
|
if [ -n "$PATTERN" ]; then
|
||||||
|
PATTERN=`nvm_format_version "$PATTERN"`
|
||||||
|
else
|
||||||
|
PATTERN=".*"
|
||||||
|
fi
|
||||||
|
VERSIONS=`nvm_download -s $NVM_NODEJS_ORG_MIRROR/ -o - \
|
||||||
|
| \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' \
|
||||||
|
| \grep -w "${PATTERN}" \
|
||||||
|
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
|
||||||
|
if [ -z "$VERSIONS" ]; then
|
||||||
|
echo "N/A"
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
|
echo "$VERSIONS"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_checksum() {
|
||||||
|
if nvm_has "sha1sum"; then
|
||||||
|
checksum=$(sha1sum $1 | \awk '{print $1}')
|
||||||
|
elif nvm_has "sha1"; then
|
||||||
|
checksum=$(sha1 -q $1)
|
||||||
|
else
|
||||||
|
checksum=$(shasum $1 | \awk '{print $1}')
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$checksum" = "$2" ]; then
|
||||||
|
return
|
||||||
|
elif [ -z "$2" ]; then
|
||||||
|
echo 'Checksums empty' #missing in raspberry pi binary
|
||||||
|
return
|
||||||
|
else
|
||||||
|
echo 'Checksums do not match.' >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_print_versions() {
|
||||||
|
local VERSION
|
||||||
|
local FORMAT
|
||||||
|
local NVM_CURRENT
|
||||||
|
NVM_CURRENT=$(nvm_ls_current)
|
||||||
|
echo "$1" | while read VERSION; do
|
||||||
|
if [ "$VERSION" = "$NVM_CURRENT" ]; then
|
||||||
|
FORMAT='\033[0;32m-> %9s\033[0m'
|
||||||
|
elif [ -d "$(nvm_version_path "$VERSION")" ]; then
|
||||||
|
FORMAT='\033[0;34m%12s\033[0m'
|
||||||
|
elif [ "$VERSION" = "system" ]; then
|
||||||
|
FORMAT='\033[0;33m%12s\033[0m'
|
||||||
|
else
|
||||||
|
FORMAT='%12s'
|
||||||
|
fi
|
||||||
|
printf "$FORMAT\n" $VERSION
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm() {
|
||||||
if [ $# -lt 1 ]; then
|
if [ $# -lt 1 ]; then
|
||||||
nvm help
|
nvm help
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Try to figure out the os and arch for binary fetching
|
||||||
|
local uname
|
||||||
|
uname="$(uname -a)"
|
||||||
|
local os
|
||||||
|
local arch
|
||||||
|
arch="$(uname -m)"
|
||||||
|
local GREP_OPTIONS
|
||||||
|
GREP_OPTIONS=''
|
||||||
|
case "$uname" in
|
||||||
|
Linux\ *) os=linux ;;
|
||||||
|
Darwin\ *) os=darwin ;;
|
||||||
|
SunOS\ *) os=sunos ;;
|
||||||
|
FreeBSD\ *) os=freebsd ;;
|
||||||
|
esac
|
||||||
|
case "$uname" in
|
||||||
|
*x86_64*) arch=x64 ;;
|
||||||
|
*i*86*) arch=x86 ;;
|
||||||
|
*armv6l*) arch=arm-pi ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# initialize local variables
|
||||||
|
local VERSION
|
||||||
|
local ADDITIONAL_PARAMETERS
|
||||||
|
local ALIAS
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
"help" )
|
"help" )
|
||||||
echo
|
echo
|
||||||
@@ -81,156 +360,452 @@ nvm()
|
|||||||
echo
|
echo
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo " nvm help Show this message"
|
echo " nvm help Show this message"
|
||||||
echo " nvm install <version> Download and install a <version>"
|
echo " nvm --version Print out the latest released version of nvm"
|
||||||
echo " nvm use <version> Modify PATH to use <version>"
|
echo " nvm install [-s] <version> Download and install a <version>, [-s] from source. Uses .nvmrc if available"
|
||||||
echo " nvm ls List versions (installed versions are blue)"
|
echo " nvm uninstall <version> Uninstall a version"
|
||||||
|
echo " nvm use <version> Modify PATH to use <version>. Uses .nvmrc if available"
|
||||||
|
echo " nvm run <version> [<args>] Run <version> with <args> as arguments. Uses .nvmrc if available for <version>"
|
||||||
|
echo " nvm current Display currently activated version"
|
||||||
|
echo " nvm ls List installed versions"
|
||||||
echo " nvm ls <version> List versions matching a given description"
|
echo " nvm ls <version> List versions matching a given description"
|
||||||
|
echo " nvm ls-remote List remote versions available for install"
|
||||||
echo " nvm deactivate Undo effects of NVM on current shell"
|
echo " nvm deactivate Undo effects of NVM on current shell"
|
||||||
echo " nvm sync Update the local cache of available versions"
|
|
||||||
echo " nvm alias [<pattern>] Show all aliases beginning with <pattern>"
|
echo " nvm alias [<pattern>] Show all aliases beginning with <pattern>"
|
||||||
echo " nvm alias <name> <version> Set an alias named <name> pointing to <version>"
|
echo " nvm alias <name> <version> Set an alias named <name> pointing to <version>"
|
||||||
|
echo " nvm unalias <name> Deletes the alias named <name>"
|
||||||
|
echo " nvm copy-packages <version> Install global NPM packages contained in <version> to current version"
|
||||||
|
echo " nvm unload Unload NVM from shell"
|
||||||
echo
|
echo
|
||||||
echo "Example:"
|
echo "Example:"
|
||||||
echo " nvm install v0.4.0 Install a specific version number"
|
echo " nvm install v0.10.24 Install a specific version number"
|
||||||
echo " nvm use stable Use the stable release"
|
echo " nvm use 0.10 Use the latest available 0.10.x release"
|
||||||
echo " nvm install latest Install the latest, possibly unstable version"
|
echo " nvm run 0.10.24 myApp.js Run myApp.js using node v0.10.24"
|
||||||
echo " nvm use 0.2 Use the latest available 0.2.x release"
|
echo " nvm alias default 0.10.24 Set default node version on a shell"
|
||||||
echo " nvm alias default v0.4.0 Set v0.4.0 as the default"
|
echo
|
||||||
|
echo "Note:"
|
||||||
|
echo " to remove, delete, or uninstall nvm - just remove ~/.nvm, ~/.npm, and ~/.bower folders"
|
||||||
echo
|
echo
|
||||||
;;
|
;;
|
||||||
"install" )
|
|
||||||
if [ $# -ne 2 ]; then
|
"install" | "i" )
|
||||||
nvm help
|
# initialize local variables
|
||||||
return
|
local binavail
|
||||||
|
local t
|
||||||
|
local url
|
||||||
|
local sum
|
||||||
|
local tarball
|
||||||
|
local nobinary
|
||||||
|
local version_not_provided
|
||||||
|
version_not_provided=0
|
||||||
|
local provided_version
|
||||||
|
|
||||||
|
if ! nvm_has "curl" && ! nvm_has "wget"; then
|
||||||
|
echo 'nvm needs curl or wget to proceed.' >&2;
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $# -lt 2 ]; then
|
||||||
|
version_not_provided=1
|
||||||
|
nvm_rc_version
|
||||||
|
if [ -z "$NVM_RC_VERSION" ]; then
|
||||||
|
nvm help
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
shift
|
||||||
|
|
||||||
|
nobinary=0
|
||||||
|
if [ "$1" = "-s" ]; then
|
||||||
|
nobinary=1
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$os" = "freebsd" ]; then
|
||||||
|
nobinary=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
provided_version=$1
|
||||||
|
if [ -z "$provided_version" ]; then
|
||||||
|
if [ $version_not_provided -ne 1 ]; then
|
||||||
|
nvm_rc_version
|
||||||
|
fi
|
||||||
|
provided_version="$NVM_RC_VERSION"
|
||||||
|
fi
|
||||||
|
[ -d "$(nvm_version_path "$provided_version")" ] && echo "$provided_version is already installed." >&2 && return
|
||||||
|
|
||||||
|
VERSION=`nvm_remote_version $provided_version`
|
||||||
|
ADDITIONAL_PARAMETERS=''
|
||||||
|
|
||||||
|
shift
|
||||||
|
|
||||||
|
while [ $# -ne 0 ]
|
||||||
|
do
|
||||||
|
ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS $1"
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -d "$(nvm_version_path "$VERSION")" ]; then
|
||||||
|
echo "$VERSION is already installed." >&2
|
||||||
|
nvm use "$VERSION"
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$VERSION" = "N/A" ]; then
|
||||||
|
echo "Version '$provided_version' not found - try \`nvm ls-remote\` to browse available versions." >&2
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
# skip binary install if no binary option specified.
|
||||||
|
if [ $nobinary -ne 1 ]; then
|
||||||
|
# shortcut - try the binary if possible.
|
||||||
|
if [ -n "$os" ]; then
|
||||||
|
if nvm_binary_available "$VERSION"; then
|
||||||
|
t="$VERSION-$os-$arch"
|
||||||
|
url="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-${t}.tar.gz"
|
||||||
|
sum=`nvm_download -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt -o - | \grep node-${t}.tar.gz | \awk '{print $1}'`
|
||||||
|
local tmpdir
|
||||||
|
tmpdir="$NVM_DIR/bin/node-${t}"
|
||||||
|
local tmptarball
|
||||||
|
tmptarball="$tmpdir/node-${t}.tar.gz"
|
||||||
|
if (
|
||||||
|
mkdir -p "$tmpdir" && \
|
||||||
|
nvm_download -L -C - --progress-bar $url -o "$tmptarball" && \
|
||||||
|
nvm_checksum "$tmptarball" $sum && \
|
||||||
|
tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
||||||
|
rm -f "$tmptarball" && \
|
||||||
|
mv "$tmpdir" "$(nvm_version_path "$VERSION")"
|
||||||
|
)
|
||||||
|
then
|
||||||
|
nvm use $VERSION
|
||||||
|
return $?
|
||||||
|
else
|
||||||
|
echo "Binary download failed, trying source." >&2
|
||||||
|
rm -rf "$tmptarball" "$tmpdir"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Additional options while compiling: $ADDITIONAL_PARAMETERS"
|
||||||
|
|
||||||
|
tarball=''
|
||||||
|
sum=''
|
||||||
|
make='make'
|
||||||
|
if [ "$os" = "freebsd" ]; then
|
||||||
|
make='gmake'
|
||||||
|
MAKE_CXX="CXX=c++"
|
||||||
|
fi
|
||||||
|
local tmpdir
|
||||||
|
tmpdir="$NVM_DIR/src"
|
||||||
|
local tmptarball
|
||||||
|
tmptarball="$tmpdir/node-$VERSION.tar.gz"
|
||||||
|
if [ "`nvm_download -s -I "$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz" -o - 2>&1 | \grep '200 OK'`" != '' ]; then
|
||||||
|
tarball="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz"
|
||||||
|
sum=`nvm_download -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt -o - | \grep node-$VERSION.tar.gz | \awk '{print $1}'`
|
||||||
|
elif [ "`nvm_download -s -I "$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz" -o - | \grep '200 OK'`" != '' ]; then
|
||||||
|
tarball="$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz"
|
||||||
fi
|
fi
|
||||||
[ "$NOCURL" ] && curl && return
|
|
||||||
VERSION=`nvm_version $2`
|
|
||||||
if (
|
if (
|
||||||
mkdir -p "$NVM_DIR/src" && \
|
[ -n "$tarball" ] && \
|
||||||
cd "$NVM_DIR/src" && \
|
mkdir -p "$tmpdir" && \
|
||||||
curl -C - -# "http://nodejs.org/dist/node-$VERSION.tar.gz" -o "node-$VERSION.tar.gz" && \
|
nvm_download -L --progress-bar $tarball -o "$tmptarball" && \
|
||||||
tar -xzf "node-$VERSION.tar.gz" && \
|
nvm_checksum "$tmptarball" $sum && \
|
||||||
cd "node-$VERSION" && \
|
tar -xzf "$tmptarball" -C "$tmpdir" && \
|
||||||
./configure --prefix="$NVM_DIR/$VERSION" && \
|
cd "$tmpdir/node-$VERSION" && \
|
||||||
make && \
|
./configure --prefix="$(nvm_version_path "$VERSION")" $ADDITIONAL_PARAMETERS && \
|
||||||
rm -f "$NVM_DIR/$VERSION" 2>/dev/null && \
|
$make $MAKE_CXX && \
|
||||||
make install
|
rm -f "$(nvm_version_path "$VERSION")" 2>/dev/null && \
|
||||||
|
$make $MAKE_CXX install
|
||||||
)
|
)
|
||||||
then
|
then
|
||||||
nvm use $VERSION
|
nvm use $VERSION
|
||||||
if ! which npm ; then
|
if ! nvm_has "npm" ; then
|
||||||
echo "Installing npm..."
|
echo "Installing npm..."
|
||||||
curl http://npmjs.org/install.sh | sh
|
if [ "`expr "$VERSION" : '\(^v0\.1\.\)'`" != '' ]; then
|
||||||
|
echo "npm requires node v0.2.3 or higher" >&2
|
||||||
|
elif [ "`expr "$VERSION" : '\(^v0\.2\.\)'`" != '' ]; then
|
||||||
|
if [ "`expr "$VERSION" : '\(^v0\.2\.[0-2]$\)'`" != '' ]; then
|
||||||
|
echo "npm requires node v0.2.3 or higher" >&2
|
||||||
|
else
|
||||||
|
nvm_download https://npmjs.org/install.sh -o - | clean=yes npm_install=0.2.19 sh
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
nvm_download https://npmjs.org/install.sh -o - | clean=yes sh
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "nvm: install $VERSION failed!"
|
echo "nvm: install $VERSION failed!" >&2
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
"uninstall" )
|
||||||
|
[ $# -ne 2 ] && nvm help && return
|
||||||
|
PATTERN=`nvm_format_version $2`
|
||||||
|
if [ "$PATTERN" = `nvm_version` ]; then
|
||||||
|
echo "nvm: Cannot uninstall currently-active node version, $PATTERN." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
VERSION=`nvm_version $PATTERN`
|
||||||
|
if [ ! -d "$(nvm_version_path "$VERSION")" ]; then
|
||||||
|
echo "$VERSION version is not installed..." >&2
|
||||||
|
return;
|
||||||
|
fi
|
||||||
|
|
||||||
|
t="$VERSION-$os-$arch"
|
||||||
|
|
||||||
|
# Delete all files related to target version.
|
||||||
|
rm -rf "$NVM_DIR/src/node-$VERSION" \
|
||||||
|
"$NVM_DIR/src/node-$VERSION.tar.gz" \
|
||||||
|
"$NVM_DIR/bin/node-${t}" \
|
||||||
|
"$NVM_DIR/bin/node-${t}.tar.gz" \
|
||||||
|
"$(nvm_version_path "$VERSION")" 2>/dev/null
|
||||||
|
echo "Uninstalled node $VERSION"
|
||||||
|
|
||||||
|
# Rm any aliases that point to uninstalled version.
|
||||||
|
for ALIAS in `\grep -l $VERSION $NVM_DIR/alias/* 2>/dev/null`
|
||||||
|
do
|
||||||
|
nvm unalias `basename $ALIAS`
|
||||||
|
done
|
||||||
|
|
||||||
|
;;
|
||||||
"deactivate" )
|
"deactivate" )
|
||||||
if [[ $PATH == *$NVM_DIR/*/bin* ]]; then
|
if [ `expr "$PATH" : ".*$NVM_DIR/.*/bin.*"` != 0 ] ; then
|
||||||
export PATH=${PATH%$NVM_DIR/*/bin*}${PATH#*$NVM_DIR/*/bin:}
|
export PATH=`nvm_strip_path "$PATH" "/bin"`
|
||||||
|
hash -r
|
||||||
echo "$NVM_DIR/*/bin removed from \$PATH"
|
echo "$NVM_DIR/*/bin removed from \$PATH"
|
||||||
else
|
else
|
||||||
echo "Could not find $NVM_DIR/*/bin in \$PATH"
|
echo "Could not find $NVM_DIR/*/bin in \$PATH" >&2
|
||||||
fi
|
fi
|
||||||
if [[ $MANPATH == *$NVM_DIR/*/share/man* ]]; then
|
if [ `expr "$MANPATH" : ".*$NVM_DIR/.*/share/man.*"` != 0 ] ; then
|
||||||
export MANPATH=${MANPATH%$NVM_DIR/*/share/man*}${MANPATH#*$NVM_DIR/*/share/man:}
|
export MANPATH=`nvm_strip_path "$MANPATH" "/share/man"`
|
||||||
echo "$NVM_DIR/*/share/man removed from \$MANPATH"
|
echo "$NVM_DIR/*/share/man removed from \$MANPATH"
|
||||||
else
|
else
|
||||||
echo "Could not find $NVM_DIR/*/share/man in \$MANPATH"
|
echo "Could not find $NVM_DIR/*/share/man in \$MANPATH" >&2
|
||||||
|
fi
|
||||||
|
if [ `expr "$NODE_PATH" : ".*$NVM_DIR/.*/lib/node_modules.*"` != 0 ] ; then
|
||||||
|
export NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
|
||||||
|
echo "$NVM_DIR/*/lib/node_modules removed from \$NODE_PATH"
|
||||||
|
else
|
||||||
|
echo "Could not find $NVM_DIR/*/lib/node_modules in \$NODE_PATH" >&2
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"use" )
|
"use" )
|
||||||
if [ $# -ne 2 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
nvm help
|
nvm help
|
||||||
return
|
return 127
|
||||||
fi
|
fi
|
||||||
VERSION=`nvm_version $2`
|
if [ $# -eq 1 ]; then
|
||||||
if [ ! -d $NVM_DIR/$VERSION ]; then
|
nvm_rc_version
|
||||||
echo "$VERSION version is not installed yet"
|
if [ -n "$NVM_RC_VERSION" ]; then
|
||||||
return;
|
VERSION=`nvm_version $NVM_RC_VERSION`
|
||||||
fi
|
fi
|
||||||
if [[ $PATH == *$NVM_DIR/*/bin* ]]; then
|
|
||||||
PATH=${PATH%$NVM_DIR/*/bin*}$NVM_DIR/$VERSION/bin${PATH#*$NVM_DIR/*/bin}
|
|
||||||
else
|
else
|
||||||
PATH="$NVM_DIR/$VERSION/bin:$PATH"
|
if [ $2 = 'system' ]; then
|
||||||
|
if nvm_has_system_node && nvm deactivate; then
|
||||||
|
echo "Now using system version of node: $(node -v 2>/dev/null)."
|
||||||
|
return
|
||||||
|
else
|
||||||
|
echo "System version of node not found." >&2
|
||||||
|
return 127
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
VERSION=`nvm_version $2`
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [[ $MANPATH == *$NVM_DIR/*/share/man* ]]; then
|
if [ -z "$VERSION" ]; then
|
||||||
MANPATH=${MANPATH%$NVM_DIR/*/share/man*}$NVM_DIR/$VERSION/share/man${MANPATH#*$NVM_DIR/*/share/man}
|
nvm help
|
||||||
else
|
return 127
|
||||||
MANPATH="$NVM_DIR/$VERSION/share/man:$MANPATH"
|
|
||||||
fi
|
fi
|
||||||
|
if [ -z "$VERSION" ]; then
|
||||||
|
VERSION=`nvm_version $2`
|
||||||
|
fi
|
||||||
|
local NVM_VERSION_DIR
|
||||||
|
NVM_VERSION_DIR="$(nvm_version_path "$VERSION")"
|
||||||
|
if [ ! -d "$NVM_VERSION_DIR" ]; then
|
||||||
|
echo "$VERSION version is not installed yet" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
# Strip other version from PATH
|
||||||
|
PATH=`nvm_strip_path "$PATH" "/bin"`
|
||||||
|
# Prepend current version
|
||||||
|
PATH=`nvm_prepend_path "$PATH" "$NVM_VERSION_DIR/bin"`
|
||||||
|
if [ -z "$MANPATH" ]; then
|
||||||
|
MANPATH=$(manpath)
|
||||||
|
fi
|
||||||
|
# Strip other version from MANPATH
|
||||||
|
MANPATH=`nvm_strip_path "$MANPATH" "/share/man"`
|
||||||
|
# Prepend current version
|
||||||
|
MANPATH=`nvm_prepend_path "$MANPATH" "$NVM_VERSION_DIR/share/man"`
|
||||||
|
# Strip other version from NODE_PATH
|
||||||
|
NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
|
||||||
|
# Prepend current version
|
||||||
|
NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_VERSION_DIR/lib/node_modules"`
|
||||||
export PATH
|
export PATH
|
||||||
|
hash -r
|
||||||
export MANPATH
|
export MANPATH
|
||||||
export NVM_PATH="$NVM_DIR/$VERSION/lib/node"
|
export NODE_PATH
|
||||||
export NVM_BIN="$NVM_DIR/$VERSION/bin"
|
export NVM_PATH="$NVM_VERSION_DIR/lib/node"
|
||||||
|
export NVM_BIN="$NVM_VERSION_DIR/bin"
|
||||||
|
if [ "$NVM_SYMLINK_CURRENT" = true ] || [ -z "$NVM_SYMLINK_CURRENT" ]; then
|
||||||
|
rm -f "$NVM_DIR/current" && ln -s "$NVM_VERSION_DIR" "$NVM_DIR/current"
|
||||||
|
fi
|
||||||
echo "Now using node $VERSION"
|
echo "Now using node $VERSION"
|
||||||
;;
|
;;
|
||||||
"ls" )
|
"run" )
|
||||||
if [ $# -ne 1 ]; then
|
local provided_version
|
||||||
nvm_version $2
|
local has_checked_nvmrc
|
||||||
return
|
has_checked_nvmrc=0
|
||||||
|
# run given version of node
|
||||||
|
shift
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
nvm_rc_version && has_checked_nvmrc=1
|
||||||
|
if [ -n "$NVM_RC_VERSION" ]; then
|
||||||
|
VERSION=`nvm_version $NVM_RC_VERSION`
|
||||||
|
else
|
||||||
|
VERSION='N/A'
|
||||||
|
fi
|
||||||
|
if [ $VERSION = "N/A" ]; then
|
||||||
|
nvm help
|
||||||
|
return 127
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
nvm_version all
|
|
||||||
for P in {stable,latest,current}; do
|
provided_version=$1
|
||||||
echo -ne "$P: \t"; nvm_version $P
|
if [ -n "$provided_version" ]; then
|
||||||
done
|
VERSION=`nvm_version $provided_version`
|
||||||
nvm alias
|
if [ $VERSION = "N/A" ]; then
|
||||||
echo "# use 'nvm sync' to update from nodejs.org"
|
provided_version=''
|
||||||
|
if [ $has_checked_nvmrc -ne 1 ]; then
|
||||||
|
nvm_rc_version && has_checked_nvmrc=1
|
||||||
|
fi
|
||||||
|
VERSION=`nvm_version $NVM_RC_VERSION`
|
||||||
|
else
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local NVM_VERSION_DIR
|
||||||
|
NVM_VERSION_DIR=$(nvm_version_path "$VERSION")
|
||||||
|
if [ ! -d "$NVM_VERSION_DIR" ]; then
|
||||||
|
echo "$VERSION version is not installed yet" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
RUN_NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`
|
||||||
|
RUN_NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_VERSION_DIR/lib/node_modules"`
|
||||||
|
echo "Running node $VERSION"
|
||||||
|
NODE_PATH=$RUN_NODE_PATH $NVM_VERSION_DIR/bin/node "$@"
|
||||||
|
;;
|
||||||
|
"exec" )
|
||||||
|
shift
|
||||||
|
|
||||||
|
local provided_version
|
||||||
|
provided_version=$1
|
||||||
|
if [ -n "$provided_version" ]; then
|
||||||
|
VERSION=`nvm_version $provided_version`
|
||||||
|
if [ $VERSION = "N/A" ]; then
|
||||||
|
provided_version=''
|
||||||
|
nvm_rc_version
|
||||||
|
VERSION=`nvm_version $NVM_RC_VERSION`
|
||||||
|
else
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local NVM_VERSION_DIR
|
||||||
|
NVM_VERSION_DIR=$(nvm_version_path "$VERSION")
|
||||||
|
if [ ! -d "$NVM_VERSION_DIR" ]; then
|
||||||
|
echo "$VERSION version is not installed yet" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
echo "Running node $VERSION"
|
||||||
|
NODE_VERSION=$VERSION $NVM_DIR/nvm-exec "$@"
|
||||||
|
;;
|
||||||
|
"ls" | "list" )
|
||||||
|
local NVM_LS_OUTPUT
|
||||||
|
local NVM_LS_EXIT_CODE
|
||||||
|
NVM_LS_OUTPUT=$(nvm_ls "$2")
|
||||||
|
NVM_LS_EXIT_CODE=$?
|
||||||
|
nvm_print_versions "$NVM_LS_OUTPUT"
|
||||||
|
if [ $# -eq 1 ]; then
|
||||||
|
nvm alias
|
||||||
|
fi
|
||||||
|
return $NVM_LS_EXIT_CODE
|
||||||
|
;;
|
||||||
|
"ls-remote" | "list-remote" )
|
||||||
|
nvm_print_versions "`nvm_ls_remote $2`"
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
"current" )
|
||||||
|
nvm_version current
|
||||||
;;
|
;;
|
||||||
"alias" )
|
"alias" )
|
||||||
mkdir -p $NVM_DIR/alias
|
mkdir -p $NVM_DIR/alias
|
||||||
if [ $# -le 2 ]; then
|
if [ $# -le 2 ]; then
|
||||||
(cd $NVM_DIR/alias && for ALIAS in `ls $2* 2>/dev/null`; do
|
local DEST
|
||||||
|
for ALIAS in $NVM_DIR/alias/$2*; do
|
||||||
|
if [ -e "$ALIAS" ]; then
|
||||||
DEST=`cat $ALIAS`
|
DEST=`cat $ALIAS`
|
||||||
VERSION=`nvm_version $DEST`
|
VERSION=`nvm_version $DEST`
|
||||||
if [ "$DEST" = "$VERSION" ]; then
|
if [ "$DEST" = "$VERSION" ]; then
|
||||||
echo "$ALIAS -> $DEST"
|
echo "$(basename $ALIAS) -> $DEST"
|
||||||
else
|
else
|
||||||
echo "$ALIAS -> $DEST (-> $VERSION)"
|
echo "$(basename $ALIAS) -> $DEST (-> $VERSION)"
|
||||||
fi
|
fi
|
||||||
done)
|
fi
|
||||||
|
done
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [ ! "$3" ]; then
|
if [ -z "$3" ]; then
|
||||||
rm -f $NVM_DIR/alias/$2
|
rm -f $NVM_DIR/alias/$2
|
||||||
echo "$2 -> *poof*"
|
echo "$2 -> *poof*"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
mkdir -p $NVM_DIR/alias
|
mkdir -p $NVM_DIR/alias
|
||||||
VERSION=`nvm_version $3`
|
VERSION=`nvm_version $3`
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "! WARNING: Version '$3' does not exist." >&2
|
echo "! WARNING: Version '$3' does not exist." >&2
|
||||||
fi
|
fi
|
||||||
echo $3 > "$NVM_DIR/alias/$2"
|
echo $3 > "$NVM_DIR/alias/$2"
|
||||||
if [ ! "$3" = "$VERSION" ]; then
|
if [ ! "$3" = "$VERSION" ]; then
|
||||||
echo "$2 -> $3 (-> $VERSION)"
|
echo "$2 -> $3 (-> $VERSION)"
|
||||||
echo "! WARNING: Moving target. Aliases to implicit versions may change without warning."
|
|
||||||
else
|
else
|
||||||
echo "$2 -> $3"
|
echo "$2 -> $3"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"sync" )
|
"unalias" )
|
||||||
[ "$NOCURL" ] && curl && return
|
mkdir -p $NVM_DIR/alias
|
||||||
LATEST=`nvm_version latest`
|
[ $# -ne 2 ] && nvm help && return 127
|
||||||
STABLE=`nvm_version stable`
|
[ ! -f "$NVM_DIR/alias/$2" ] && echo "Alias $2 doesn't exist!" >&2 && return
|
||||||
(cd $NVM_DIR
|
rm -f $NVM_DIR/alias/$2
|
||||||
rm -f v* 2>/dev/null
|
echo "Deleted alias $2"
|
||||||
printf "# syncing with nodejs.org..."
|
;;
|
||||||
for VER in `curl -s http://nodejs.org/dist/ -o - | grep 'node-v.*\.tar\.gz' | sed -e 's/.*node-//' -e 's/\.tar\.gz.*//'`; do
|
"copy-packages" )
|
||||||
touch $VER
|
if [ $# -ne 2 ]; then
|
||||||
done
|
nvm help
|
||||||
echo " done."
|
return 127
|
||||||
)
|
fi
|
||||||
[ "$STABLE" = `nvm_version stable` ] || echo "NEW stable: `nvm_version stable`"
|
VERSION="$(nvm_version "$2")"
|
||||||
[ "$LATEST" = `nvm_version latest` ] || echo "NEW latest: `nvm_version latest`"
|
|
||||||
|
# declare local INSTALLS first, otherwise it doesn't work in zsh
|
||||||
|
local INSTALLS
|
||||||
|
INSTALLS=$(nvm use "$VERSION" > /dev/null && npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | xargs)
|
||||||
|
|
||||||
|
echo "$INSTALLS" | xargs npm install -g --quiet
|
||||||
;;
|
;;
|
||||||
"clear-cache" )
|
"clear-cache" )
|
||||||
rm -f $NVM_DIR/v* 2>/dev/null
|
rm -f $NVM_DIR/v* "$(nvm_version_dir)" 2>/dev/null
|
||||||
echo "Cache cleared."
|
echo "Cache cleared."
|
||||||
;;
|
;;
|
||||||
"version" )
|
"version" )
|
||||||
nvm_version $2
|
nvm_version $2
|
||||||
|
;;
|
||||||
|
"--version" )
|
||||||
|
echo "0.15.0"
|
||||||
|
;;
|
||||||
|
"unload" )
|
||||||
|
unset -f nvm nvm_print_versions nvm_checksum nvm_ls_remote nvm_ls nvm_remote_version nvm_version nvm_rc_version nvm_version_greater > /dev/null 2>&1
|
||||||
|
unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_DIR NVM_CD_FLAGS > /dev/null 2>&1
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
nvm help
|
nvm help
|
||||||
@@ -238,4 +813,5 @@ nvm()
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm ls default >/dev/null 2>&1 && nvm use default >/dev/null
|
nvm ls default >/dev/null && nvm use default >/dev/null || true
|
||||||
|
|
||||||
|
|||||||
37
package.json
37
package.json
@@ -1,6 +1,33 @@
|
|||||||
{ "name" : "nvm"
|
{
|
||||||
, "version" : "0.1.0"
|
"name": "nvm",
|
||||||
, "author" : "Tim Caswell <tim@creationix.org>"
|
"version": "0.15.0",
|
||||||
, "scripts" :
|
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
|
||||||
{ "install" : "./install.sh" , "uninstall" : "./uninstall.sh" }
|
"directories": {
|
||||||
|
"test": "test"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "urchin test",
|
||||||
|
"test/fast": "urchin -f test/fast",
|
||||||
|
"test/slow": "urchin -f test/slow"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/creationix/nvm.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"nvm",
|
||||||
|
"node",
|
||||||
|
"version",
|
||||||
|
"manager"
|
||||||
|
],
|
||||||
|
"author": "Tim Caswell <tim@creationix.com>",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/creationix/nvm/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/creationix/nvm",
|
||||||
|
"devDependencies": {
|
||||||
|
"urchin": "~0.0.2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
[ $(nvm alias test1 | wc -l) = '2' ]
|
||||||
4
test/fast/Aliases/Running "nvm alias" should list all aliases.
Executable file
4
test/fast/Aliases/Running "nvm alias" should list all aliases.
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
[ $(nvm alias | wc -l) = '10' ]
|
||||||
6
test/fast/Aliases/setup_dir
Executable file
6
test/fast/Aliases/setup_dir
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
for i in $(seq 1 10)
|
||||||
|
do
|
||||||
|
echo v0.0.$i > ../../../alias/test$i
|
||||||
|
done
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
mkdir ../../../v0.1.3
|
||||||
|
mkdir ../../../v0.2.3
|
||||||
|
mkdir ../../../v0.20.3
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
# The result should contain only the appropriate version numbers.
|
||||||
|
|
||||||
|
nvm ls 0.1 | grep 'v0.2.3' > /dev/null
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo '"nvm ls 0.1" contained v0.2.3'
|
||||||
|
fi
|
||||||
|
|
||||||
|
nvm ls 0.1 | grep 'v0.20.3' > /dev/null
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
die '"nvm ls 0.1" contained v0.20.3'
|
||||||
|
fi
|
||||||
|
|
||||||
|
nvm ls 0.1 | grep 'v0.1.3' > /dev/null
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
die '"nvm ls 0.1" did not contain v0.1.3'
|
||||||
|
fi
|
||||||
|
|
||||||
|
nvm ls 0.2 | grep 'v0.2.3' > /dev/null
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
die '"nvm ls 0.2" did not contain v0.2.3'
|
||||||
|
fi
|
||||||
|
|
||||||
|
nvm ls 0.2 | grep 'v0.20.3' > /dev/null
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
die '"nvm ls 0.2" contained v0.20.3'
|
||||||
|
fi
|
||||||
|
|
||||||
|
nvm ls 0.2 | grep 'v0.2.3' > /dev/null
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
die '"nvm ls 0.2" did not contain v0.2.3'
|
||||||
|
fi
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm ls nonexistent_version
|
||||||
|
[ "$?" = "3" ]
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm ls node
|
||||||
|
[ "$?" = "3" ]
|
||||||
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
mkdir ../../../v0.0.1
|
||||||
|
mkdir ../../../v0.0.3
|
||||||
|
mkdir ../../../v0.0.9
|
||||||
|
mkdir ../../../v0.3.1
|
||||||
|
mkdir ../../../v0.3.3
|
||||||
|
mkdir ../../../v0.3.9
|
||||||
|
|
||||||
|
# The result should contain the version numbers.
|
||||||
|
nvm ls | grep v0.0.1 &&
|
||||||
|
nvm ls | grep v0.0.3 &&
|
||||||
|
nvm ls | grep v0.0.9 &&
|
||||||
|
nvm ls | grep v0.3.1 &&
|
||||||
|
nvm ls | grep v0.3.3 &&
|
||||||
|
nvm ls | grep v0.3.9
|
||||||
9
test/fast/Listing versions/Running "nvm ls" should filter out ".nvm"
Executable file
9
test/fast/Listing versions/Running "nvm ls" should filter out ".nvm"
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
mkdir ../../../v0.1.3
|
||||||
|
mkdir ../../../v0.2.3
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
[ -z `nvm ls | grep '^ *\.'` ]
|
||||||
|
# The result should contain only the appropriate version numbers.
|
||||||
14
test/fast/Listing versions/Running "nvm ls" should filter out "versions"
Executable file
14
test/fast/Listing versions/Running "nvm ls" should filter out "versions"
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
mkdir ../../../v0.1.3
|
||||||
|
mkdir ../../../v0.2.3
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
mkdir ../../../versions
|
||||||
|
|
||||||
|
[ -z "$(nvm ls | \grep 'versions')" ]
|
||||||
|
# The result should contain only the appropriate version numbers.
|
||||||
|
|
||||||
|
rmdir ../../../versions
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
mkdir -p ../../../v0.0.1
|
||||||
|
mkdir -p ../../../v0.0.3
|
||||||
|
mkdir -p ../../../v0.0.9
|
||||||
|
mkdir -p ../../../v0.3.1
|
||||||
|
mkdir -p ../../../v0.3.3
|
||||||
|
mkdir -p ../../../v0.3.9
|
||||||
|
|
||||||
|
nvm_has_system_node() { return 0; }
|
||||||
|
nvm ls | grep system 2>&1 > /dev/null
|
||||||
|
[ $? -eq 0 ] || die '"nvm ls" did not contain "system" when system node is present'
|
||||||
|
|
||||||
|
nvm_has_system_node() { return 1; }
|
||||||
|
nvm ls | grep system 2>&1 > /dev/null
|
||||||
|
[ $? -ne 0 ] || die '"nvm ls" contained "system" when system node is not present'
|
||||||
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
mkdir -p ../../../versions/v0.12.1
|
||||||
|
mkdir ../../../v0.1.3
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm ls 0.12 | grep v0.12.1 || die '"nvm ls" did not list a version in the versions/ directory'
|
||||||
|
nvm ls 0.1 | grep v0.1.3 || die '"nvm ls" did not list a version not in the versions/ directory'
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
mkdir ../../../v0.1.2
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm ls v0.1 | grep v0.1.2 &&
|
||||||
|
nvm ls v0.1.2 | grep v0.1.2 &&
|
||||||
|
nvm ls v0.1. | grep N/A &&
|
||||||
|
nvm ls v0.1.1 | grep N/A
|
||||||
|
|
||||||
12
test/fast/Listing versions/teardown
Normal file
12
test/fast/Listing versions/teardown
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
rmdir ../../../v0.0.1
|
||||||
|
rmdir ../../../v0.0.3
|
||||||
|
rmdir ../../../v0.0.9
|
||||||
|
rmdir ../../../v0.1.2
|
||||||
|
rmdir ../../../v0.1.3
|
||||||
|
rmdir ../../../v0.2.3
|
||||||
|
rmdir ../../../v0.3.1
|
||||||
|
rmdir ../../../v0.3.3
|
||||||
|
rmdir ../../../v0.3.9
|
||||||
|
rmdir ../../../versions
|
||||||
|
unalias nvm_has_system_node
|
||||||
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
nvm alias test v0.1.2
|
||||||
|
[ "$(cat ../../alias/test)" = "v0.1.2" ]
|
||||||
10
test/fast/Running "nvm current" should display current nvm environment.
Executable file
10
test/fast/Running "nvm current" should display current nvm environment.
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
nvm deactivate 2>&1
|
||||||
|
|
||||||
|
[ "$(nvm current)" = "system" ] || [ "$(nvm current)" = "none" ] || die '"nvm current" did not report "system" or "none" when deactivated'
|
||||||
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
mkdir -p ../../v0.2.3
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&2
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
nvm use v0.2.3 &&
|
||||||
|
[ `expr $PATH : ".*v0.2.3/.*/bin"` != 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` != 0 ] || die "Failed to activate v0.2.3"
|
||||||
|
|
||||||
|
nvm deactivate &&
|
||||||
|
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] && [ `expr $NODE_PATH : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "Failed to deactivate v0.2.3"
|
||||||
7
test/fast/Running "nvm install" with an invalid version fails nicely
Executable file
7
test/fast/Running "nvm install" with an invalid version fails nicely
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
[ "$(nvm install invalid.invalid 2>&1)" = "Version 'invalid.invalid' not found - try \`nvm ls-remote\` to browse available versions." ] || die "nvm installing an invalid version did not print a nice error message"
|
||||||
|
|
||||||
6
test/fast/Running "nvm unalias" should remove the alias file.
Executable file
6
test/fast/Running "nvm unalias" should remove the alias file.
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo v0.1.2 > ../../alias/test
|
||||||
|
. ../../nvm.sh
|
||||||
|
nvm unalias test
|
||||||
|
! [ -e ../../alias/test ]
|
||||||
10
test/fast/Running "nvm uninstall" should remove the appropriate directory.
Executable file
10
test/fast/Running "nvm uninstall" should remove the appropriate directory.
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd ../..
|
||||||
|
mkdir v0.0.1
|
||||||
|
mkdir src/node-v0.0.1
|
||||||
|
|
||||||
|
. ./nvm.sh
|
||||||
|
nvm uninstall v0.0.1
|
||||||
|
|
||||||
|
[ ! -d 'v0.0.1' ] && [ ! -d 'src/node-v0.0.1' ]
|
||||||
12
test/fast/Running "nvm unload" should unset all function and variables.
Executable file
12
test/fast/Running "nvm unload" should unset all function and variables.
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
fail () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
type nvm > /dev/null 2>&1 || fail "NVM not loaded"
|
||||||
|
|
||||||
|
nvm unload
|
||||||
|
|
||||||
|
type nvm > /dev/null 2>&1 && fail "NVM not unloaded" || exit 0
|
||||||
|
|
||||||
13
test/fast/Running "nvm use system" should work as expected
Executable file
13
test/fast/Running "nvm use system" should work as expected
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
nvm_has_system_node() { return 0; }
|
||||||
|
[ "$(nvm use system 2>&1 | tail -n1)" = "Now using system version of node: $(node -v)." ] || die "Could not use system version of node"
|
||||||
|
|
||||||
|
nvm_has_system_node() { return 1; }
|
||||||
|
[ "$(nvm use system 2>&1 | tail -n1)" = "System version of node not found." ] || die "Did not report error, system node not found"
|
||||||
|
nvm use system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found"
|
||||||
|
|
||||||
32
test/fast/Running "nvm use x" should create and change the "current" symlink
Executable file
32
test/fast/Running "nvm use x" should create and change the "current" symlink
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
rm -rf ../../v0.10.29
|
||||||
|
mkdir ../../v0.10.29
|
||||||
|
nvm use 0.10.29
|
||||||
|
rmdir ../../v0.10.29
|
||||||
|
|
||||||
|
if [ ! -L ../../current ];then
|
||||||
|
echo "Expected 'current' symlink to be created!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
oldLink="$(readlink ../../current)"
|
||||||
|
|
||||||
|
if [ "$(basename $oldLink)" != 'v0.10.29' ];then
|
||||||
|
echo "Expected 'current' to point to v0.10.29 but was $oldLink"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf ../../v0.11.13
|
||||||
|
mkdir ../../v0.11.13
|
||||||
|
nvm use 0.11.13
|
||||||
|
rmdir ../../v0.11.13
|
||||||
|
|
||||||
|
newLink="$(readlink ../../current)"
|
||||||
|
|
||||||
|
if [ "$(basename $newLink)" != 'v0.11.13' ];then
|
||||||
|
echo "Expected 'current' to point to v0.11.13 but was $newLink"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
TEST_NODE_VERSION="v0.10.29"
|
||||||
|
|
||||||
|
TEST_COUNT=0
|
||||||
|
TEST_PASSED=0
|
||||||
|
TEST_FAILED=0
|
||||||
|
|
||||||
|
function registerExpectedSymlink() {
|
||||||
|
registerResult ${1}
|
||||||
|
}
|
||||||
|
|
||||||
|
function registerExpectedNoSymlink() {
|
||||||
|
[ ${1} -ne 0 ]
|
||||||
|
registerResult $?
|
||||||
|
}
|
||||||
|
|
||||||
|
function registerResult() {
|
||||||
|
result=${1}
|
||||||
|
|
||||||
|
TEST_COUNT=$(($TEST_COUNT + 1))
|
||||||
|
|
||||||
|
[ ${result} -eq 0 ] \
|
||||||
|
&& TEST_PASSED=$(($TEST_PASSED + 1)) \
|
||||||
|
|| TEST_FAILED=$(($TEST_FAILED + 1))
|
||||||
|
}
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
rm -rf ../../${TEST_NODE_VERSION}
|
||||||
|
rm -f ../../current
|
||||||
|
}
|
||||||
|
|
||||||
|
function runNvmUse() {
|
||||||
|
mkdir ../../${TEST_NODE_VERSION}
|
||||||
|
nvm use ${TEST_NODE_VERSION} &> /dev/null
|
||||||
|
rmdir ../../${TEST_NODE_VERSION}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isCurrentSymlinkPresent() {
|
||||||
|
[ -L ../../current ]
|
||||||
|
}
|
||||||
|
|
||||||
|
NVM_SYMLINK_CURRENT=false
|
||||||
|
cleanup
|
||||||
|
runNvmUse
|
||||||
|
isCurrentSymlinkPresent && echo "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=false!"
|
||||||
|
registerExpectedNoSymlink $?
|
||||||
|
|
||||||
|
NVM_SYMLINK_CURRENT=true
|
||||||
|
cleanup
|
||||||
|
runNvmUse
|
||||||
|
isCurrentSymlinkPresent || echo "Expected 'current' symlink to be created when NVM_SYMLINK_CURRENT=true!"
|
||||||
|
registerExpectedSymlink $?
|
||||||
|
|
||||||
|
NVM_SYMLINK_CURRENT=garbagevalue
|
||||||
|
cleanup
|
||||||
|
runNvmUse
|
||||||
|
isCurrentSymlinkPresent && echo "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT contains a string!"
|
||||||
|
registerExpectedNoSymlink $?
|
||||||
|
|
||||||
|
NVM_SYMLINK_CURRENT=0
|
||||||
|
cleanup
|
||||||
|
runNvmUse
|
||||||
|
isCurrentSymlinkPresent && echo "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=0!"
|
||||||
|
registerExpectedNoSymlink $?
|
||||||
|
|
||||||
|
NVM_SYMLINK_CURRENT=1
|
||||||
|
cleanup
|
||||||
|
runNvmUse
|
||||||
|
isCurrentSymlinkPresent && echo "Expected 'current' symlink not to be created when NVM_SYMLINK_CURRENT=1!"
|
||||||
|
registerExpectedNoSymlink $?
|
||||||
|
|
||||||
|
unset NVM_SYMLINK_CURRENT
|
||||||
|
cleanup
|
||||||
|
runNvmUse
|
||||||
|
isCurrentSymlinkPresent || echo "Expected 'current' symlink to be created when NVM_SYMLINK_CURRENT has been unset (default behaviour)!"
|
||||||
|
registerExpectedSymlink $?
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
|
[ ${TEST_FAILED} -ne 0 ] && echo "${TEST_COUNT} tested, ${TEST_PASSED} passed, ${TEST_FAILED} failed" && exit 1 || true
|
||||||
4
test/fast/Sourcing nvm.sh should make the nvm command available.
Executable file
4
test/fast/Sourcing nvm.sh should make the nvm command available.
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
nvm
|
||||||
18
test/fast/Unit tests/nvm_checksum
Executable file
18
test/fast/Unit tests/nvm_checksum
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cleanup () {
|
||||||
|
rm tmp/emptyfile tmp/testfile
|
||||||
|
rmdir tmp
|
||||||
|
}
|
||||||
|
die () { echo $@ ; cleanup; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
mkdir -p tmp
|
||||||
|
touch tmp/emptyfile
|
||||||
|
echo -n "test" > tmp/testfile
|
||||||
|
|
||||||
|
nvm_checksum tmp/emptyfile "da39a3ee5e6b4b0d3255bfef95601890afd80709" || die "nvm_checksum on an empty file did not match the SHA1 digest of the empty string"
|
||||||
|
nvm_checksum tmp/testfile "da39a3ee5e6b4b0d3255bfef95601890afd80709" && die "nvm_checksum allowed a bad checksum"
|
||||||
|
|
||||||
|
cleanup
|
||||||
29
test/fast/Unit tests/nvm_has_system_node
Executable file
29
test/fast/Unit tests/nvm_has_system_node
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cleanup () {
|
||||||
|
rm ../../../v0.1.2/node
|
||||||
|
rmdir ../../../v0.1.2
|
||||||
|
}
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
mkdir ../../../v0.1.2
|
||||||
|
touch ../../../v0.1.2/node
|
||||||
|
|
||||||
|
nvm use 0.1.2
|
||||||
|
|
||||||
|
if command -v node; then
|
||||||
|
nvm_has_system_node
|
||||||
|
else
|
||||||
|
! nvm_has_system_node
|
||||||
|
fi
|
||||||
|
|
||||||
|
nvm deactivate /dev/null 2>&1
|
||||||
|
|
||||||
|
if command -v node; then
|
||||||
|
nvm_has_system_node
|
||||||
|
else
|
||||||
|
! nvm_has_system_node
|
||||||
|
fi
|
||||||
|
|
||||||
28
test/fast/Unit tests/nvm_ls_current
Executable file
28
test/fast/Unit tests/nvm_ls_current
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
return_zero () { return 0; }
|
||||||
|
|
||||||
|
[ "$( (nvm deactivate > /dev/null 2>&1) && nvm_ls_current)" = "system" ] || die 'when deactivated, did not return "system"'
|
||||||
|
|
||||||
|
TEST_PWD=$(pwd)
|
||||||
|
TEST_DIR="$TEST_PWD/nvm_ls_current_tmp"
|
||||||
|
rm -rf "$TEST_DIR"
|
||||||
|
mkdir "$TEST_DIR"
|
||||||
|
ln -s "$(which which)" "$TEST_DIR/which"
|
||||||
|
ln -s "$(which dirname)" "$TEST_DIR/dirname"
|
||||||
|
|
||||||
|
[ "$(PATH="$TEST_DIR" nvm_ls_current)" = "none" ] || die 'when node not installed, nvm_ls_current did not return "none"'
|
||||||
|
[ "@$(PATH="$TEST_DIR" nvm_ls_current 2> /dev/stdout 1> /dev/null)@" = "@@" ] || die 'when node not installed, nvm_ls_current returned error output'
|
||||||
|
|
||||||
|
echo "#!/bin/bash" > "$TEST_DIR/node"
|
||||||
|
echo "echo 'VERSION FOO!'" > "$TEST_DIR/node"
|
||||||
|
chmod a+x "$TEST_DIR/node"
|
||||||
|
|
||||||
|
[ "$(alias nvm_tree_contains_path='return_zero' && PATH="$TEST_DIR" nvm_ls_current)" = "VERSION FOO!" ] || die 'when activated, did not return nvm node version'
|
||||||
|
|
||||||
|
rm -rf "$TEST_DIR"
|
||||||
|
|
||||||
18
test/fast/Unit tests/nvm_prepend_path
Executable file
18
test/fast/Unit tests/nvm_prepend_path
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
TEST_PATH=/usr/bin:/usr/local/bin
|
||||||
|
|
||||||
|
NEW_PATH=`nvm_prepend_path "$TEST_PATH" "$NVM_DIR/v0.2.5/bin"`
|
||||||
|
|
||||||
|
[ "$NEW_PATH" = "$NVM_DIR/v0.2.5/bin:/usr/bin:/usr/local/bin" ] || die "Not correctly prepended: $NEW_PATH "
|
||||||
|
|
||||||
|
|
||||||
|
EMPTY_PATH=
|
||||||
|
|
||||||
|
NEW_PATH=`nvm_prepend_path "$EMPTY_PATH" "$NVM_DIR/v0.2.5/bin"`
|
||||||
|
|
||||||
|
[ "$NEW_PATH" = "$NVM_DIR/v0.2.5/bin" ] || die "Not correctly prepended: $NEW_PATH "
|
||||||
11
test/fast/Unit tests/nvm_strip_path
Executable file
11
test/fast/Unit tests/nvm_strip_path
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
TEST_PATH=$NVM_DIR/v0.10.5/bin:/usr/bin:$NVM_DIR/v0.11.5/bin:$NVM_DIR/v0.9.5/bin:/usr/local/bin:$NVM_DIR/v0.2.5/bin
|
||||||
|
|
||||||
|
STRIPPED_PATH=`nvm_strip_path "$TEST_PATH" "/bin"`
|
||||||
|
|
||||||
|
[ "$STRIPPED_PATH" = "/usr/bin:/usr/local/bin" ] || die "Not correctly stripped: $STRIPPED_PATH "
|
||||||
32
test/fast/Unit tests/nvm_tree_contains_path
Executable file
32
test/fast/Unit tests/nvm_tree_contains_path
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cleanup () {
|
||||||
|
rm tmp/node
|
||||||
|
rmdir tmp
|
||||||
|
rm tmp2/node
|
||||||
|
rmdir tmp2
|
||||||
|
}
|
||||||
|
die () { echo $@ ; cleanup; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
mkdir -p tmp
|
||||||
|
touch tmp/node
|
||||||
|
mkdir -p tmp2
|
||||||
|
touch tmp2/node
|
||||||
|
|
||||||
|
[ "$(nvm_tree_contains_path 2>&1)" = "both the tree and the node path are required" ] || die 'incorrect error message with no args'
|
||||||
|
[ "$(nvm_tree_contains_path > /dev/null 2>&1 ; echo $?)" = "2" ] || die 'incorrect error code with no args'
|
||||||
|
[ "$(nvm_tree_contains_path tmp 2>&1)" = "both the tree and the node path are required" ] || die 'incorrect error message with one arg'
|
||||||
|
[ "$(nvm_tree_contains_path > /dev/null 2>&1 ; echo $?)" = "2" ] || die 'incorrect error code with one arg'
|
||||||
|
|
||||||
|
nvm_tree_contains_path tmp tmp/node || die '"tmp" should contain "tmp/node"'
|
||||||
|
|
||||||
|
nvm_tree_contains_path tmp tmp2/node && die '"tmp" should not contain "tmp2/node"'
|
||||||
|
|
||||||
|
nvm_tree_contains_path tmp2 tmp2/node || die '"tmp2" should contain "tmp2/node"'
|
||||||
|
|
||||||
|
nvm_tree_contains_path tmp2 tmp/node && die '"tmp2" should not contain "tmp/node"'
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
|
||||||
11
test/fast/Unit tests/nvm_version_dir
Executable file
11
test/fast/Unit tests/nvm_version_dir
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
[ "$(nvm_version_dir)" = "$NVM_DIR/versions" ] || die '"nvm_version_dir" did not return new dir path'
|
||||||
|
[ "$(nvm_version_dir new)" = "$(nvm_version_dir)" ] || die '"nvm_version_dir new" did not return new dir path'
|
||||||
|
[ "$(nvm_version_dir old)" = "$NVM_DIR" ] || die '"nvm_version_dir old" did not return old dir path'
|
||||||
|
[ "$(nvm_version_dir foo 2>&1)" = "unknown version dir" ] || die '"nvm_version_dir foo" did not error out'
|
||||||
|
|
||||||
16
test/fast/Unit tests/nvm_version_greater
Executable file
16
test/fast/Unit tests/nvm_version_greater
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm_version_greater 0.10.0 0.2.12 || die '"nvm_version_greater 0.10.0 0.2.12" did not return true'
|
||||||
|
|
||||||
|
if nvm_version_greater 0.10.0 0.20.12; then
|
||||||
|
die '"nvm_version_greater 0.10.0 0.20.12" returned true'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if nvm_version_greater 0.10.0 0.10.0; then
|
||||||
|
die '"nvm_version_greater" returned false for the same two versions'
|
||||||
|
fi
|
||||||
|
|
||||||
11
test/fast/Unit tests/nvm_version_path
Executable file
11
test/fast/Unit tests/nvm_version_path
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
[ "$(nvm_version_path foo)" = "$NVM_DIR/foo" ] || die '"nvm_version_path foo" did not return correct location'
|
||||||
|
[ "$(nvm_version_path 2>&1)" = "version is required" ] || die '"nvm_version_path" did not error out'
|
||||||
|
[ "$(nvm_version_path v0.11.0)" = "$NVM_DIR/v0.11.0" ] || die 'old version has the wrong path'
|
||||||
|
[ "$(nvm_version_path v0.12.0)" = "$NVM_DIR/versions/v0.12.0" ] || die 'new version has the wrong path'
|
||||||
|
|
||||||
12
test/fast/setup
Executable file
12
test/fast/setup
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
(
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Back up
|
||||||
|
|
||||||
|
type setopt >/dev/null 2>&1 && setopt NULL_GLOB
|
||||||
|
type shopt >/dev/null 2>&1 && shopt -s nullglob
|
||||||
|
rm -Rf v* src alias
|
||||||
|
mkdir src alias
|
||||||
|
)
|
||||||
16
test/fast/setup_dir
Executable file
16
test/fast/setup_dir
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
(
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Back up
|
||||||
|
|
||||||
|
mkdir -p bak
|
||||||
|
for SRC in v* src alias; do
|
||||||
|
[ -e "$SRC" ] && mv "$SRC" bak
|
||||||
|
done
|
||||||
|
if [ -d versions ]; then
|
||||||
|
mv versions bak
|
||||||
|
fi
|
||||||
|
true
|
||||||
|
)
|
||||||
10
test/fast/teardown
Executable file
10
test/fast/teardown
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Remove temporary files
|
||||||
|
(
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
type setopt >/dev/null 2>&1 && setopt NULL_GLOB
|
||||||
|
type shopt >/dev/null 2>&1 && shopt -s nullglob
|
||||||
|
rm -fR v* src alias
|
||||||
|
)
|
||||||
13
test/fast/teardown_dir
Executable file
13
test/fast/teardown_dir
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
(
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Restore
|
||||||
|
if [ -d bak ]
|
||||||
|
then
|
||||||
|
mv bak/* . > /dev/null 2>&1 || sleep 0s
|
||||||
|
rmdir bak
|
||||||
|
fi
|
||||||
|
mkdir -p src alias
|
||||||
|
)
|
||||||
14
test/slow/Running "nvm current" should display current nvm environment.
Executable file
14
test/slow/Running "nvm current" should display current nvm environment.
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
nvm install 0.10
|
||||||
|
|
||||||
|
[ "$(nvm current)" = "$(node -v)" ] || die "Failed to find current version: got \"$(nvm current)\", expected \"$(node -v)\""
|
||||||
|
|
||||||
|
nvm install 0.6.21
|
||||||
|
[ "$(node -v)" = "v0.6.21-pre" ] || die "v0.6.21-pre not installed with v0.6.21"
|
||||||
|
[ "$(nvm current)" = "v0.6.21" ] || die "v0.6.21-pre not reported as v0.6.21"
|
||||||
|
|
||||||
10
test/slow/nvm copy-packages/setup_dir
Executable file
10
test/slow/nvm copy-packages/setup_dir
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
nvm install 0.10.28
|
||||||
|
nvm install 0.10.29
|
||||||
|
|
||||||
|
if [ -f ".nvmrc" ]; then
|
||||||
|
mv .nvmrc .nvmrc.bak
|
||||||
|
fi
|
||||||
|
|
||||||
21
test/slow/nvm copy-packages/should work as expected
Executable file
21
test/slow/nvm copy-packages/should work as expected
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo "$@" ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm use 0.10.28
|
||||||
|
|
||||||
|
EXPECTED_PACKAGES="autoprefixer bower david eslint grunt-cli grunth-cli http-server jshint marked node-gyp recursive-blame uglify-js yo"
|
||||||
|
|
||||||
|
echo "$EXPECTED_PACKAGES" | xargs npm install -g --quiet
|
||||||
|
|
||||||
|
nvm use 0.10.29
|
||||||
|
ORIGINAL_PACKAGES=$(npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | sort | uniq | xargs)
|
||||||
|
|
||||||
|
nvm copy-packages 0.10.28
|
||||||
|
FINAL_PACKAGES=$(npm list -g --depth=0 | tail -n +2 | \grep -o -e ' [^@]*' | cut -c 2- | \grep -v npm | sort | uniq | xargs)
|
||||||
|
|
||||||
|
[ "$FINAL_PACKAGES" = "$EXPECTED_PACKAGES" ] || die "final packages ($FINAL_PACKAGES) did not match expected packages ($EXPECTED_PACKAGES)"
|
||||||
|
[ "$ORIGINAL_PACKAGES" != "$FINAL_PACKAGES" ] || die "original packages matched final packages ($ORIGINAL_PACKAGES)"
|
||||||
|
|
||||||
12
test/slow/nvm copy-packages/teardown_dir
Executable file
12
test/slow/nvm copy-packages/teardown_dir
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
nvm uninstall v0.10.28
|
||||||
|
nvm uninstall v0.10.29
|
||||||
|
|
||||||
|
rm -f .nvmrc
|
||||||
|
|
||||||
|
if [ -f ".nvmrc.bak" ]; then
|
||||||
|
mv .nvmrc.bak .nvmrc
|
||||||
|
fi
|
||||||
|
|
||||||
13
test/slow/nvm exec/Running "nvm exec 0.x" should work
Executable file
13
test/slow/nvm exec/Running "nvm exec 0.x" should work
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm use 0.10
|
||||||
|
NPM_VERSION_TEN="$(npm --version)"
|
||||||
|
|
||||||
|
nvm use 0.11.7 && [ "$(node --version)" = "v0.11.7" ] || die "\`nvm use\` failed!"
|
||||||
|
|
||||||
|
[ "$(nvm exec 0.10 npm --version | tail -1)" = "$NPM_VERSION_TEN" ] || die "`nvm exec` failed to run with the correct version"
|
||||||
|
|
||||||
17
test/slow/nvm exec/Running "nvm exec" should pick up .nvmrc version
Executable file
17
test/slow/nvm exec/Running "nvm exec" should pick up .nvmrc version
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
nvm use 0.10.7
|
||||||
|
NPM_VERSION_TEN="$(npm --version)"
|
||||||
|
|
||||||
|
nvm use 0.11.7 && [ "$(node --version)" = "v0.11.7" ] || die "\`nvm use\` failed!"
|
||||||
|
|
||||||
|
echo "0.10.7" > .nvmrc
|
||||||
|
|
||||||
|
[ "$(nvm exec npm --version | tail -1)" = "$NPM_VERSION_TEN" ] || die "\`nvm exec\` failed to run with the .nvmrc version"
|
||||||
|
|
||||||
|
[ "$(nvm exec npm --version | head -1)" = "Found '$PWD/.nvmrc' with version <0.10.7>" ] || die "\`nvm exec\` failed to print out the \"found in .nvmrc\" message"
|
||||||
|
|
||||||
10
test/slow/nvm exec/setup_dir
Executable file
10
test/slow/nvm exec/setup_dir
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
nvm install 0.10.7
|
||||||
|
nvm install 0.11.7
|
||||||
|
|
||||||
|
if [ -f ".nvmrc" ]; then
|
||||||
|
mv .nvmrc .nvmrc.bak
|
||||||
|
fi
|
||||||
|
|
||||||
12
test/slow/nvm exec/teardown_dir
Executable file
12
test/slow/nvm exec/teardown_dir
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
nvm uninstall v0.10.7
|
||||||
|
nvm uninstall v0.11.7
|
||||||
|
|
||||||
|
rm .nvmrc
|
||||||
|
|
||||||
|
if [ -f ".nvmrc.bak" ]; then
|
||||||
|
mv .nvmrc.bak .nvmrc
|
||||||
|
fi
|
||||||
|
|
||||||
24
test/slow/nvm install/install already installed uses it
Executable file
24
test/slow/nvm install/install already installed uses it
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
[ "$(nvm install invalid.invalid 2>&1)" = "Version 'invalid.invalid' not found - try \`nvm ls-remote\` to browse available versions." ] || die "nvm installing an invalid version did not print a nice error message"
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../../v0.9.7 ] && rm -R ../../../v0.9.7
|
||||||
|
[ -e ../../../v0.9.12 ] && rm -R ../../../v0.9.12
|
||||||
|
|
||||||
|
# Install from binary
|
||||||
|
nvm install 0.9.7
|
||||||
|
nvm install 0.9.12
|
||||||
|
|
||||||
|
nvm use 0.9.7
|
||||||
|
|
||||||
|
node --version | grep v0.9.7 || die "precondition failed: node doesn't start at 0.9.7"
|
||||||
|
|
||||||
|
nvm install 0.9.12
|
||||||
|
|
||||||
|
node --version | grep v0.9.12 || die "nvm install on already installed version doesn't use it"
|
||||||
|
|
||||||
17
test/slow/nvm install/install from binary
Executable file
17
test/slow/nvm install/install from binary
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
NVM_TEST_VERSION=v0.10.7
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
||||||
|
|
||||||
|
# Install from binary
|
||||||
|
nvm install $NVM_TEST_VERSION
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d ../../../$NVM_TEST_VERSION ]
|
||||||
|
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION
|
||||||
|
|
||||||
17
test/slow/nvm install/install from source
Executable file
17
test/slow/nvm install/install from source
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
NVM_TEST_VERSION=v0.10.7
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
||||||
|
|
||||||
|
# Install from source
|
||||||
|
nvm install -s $NVM_TEST_VERSION
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d ../../../$NVM_TEST_VERSION ]
|
||||||
|
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION
|
||||||
|
|
||||||
24
test/slow/nvm install/install two versions and use the latest one
Executable file
24
test/slow/nvm install/install two versions and use the latest one
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../../v0.9.7 ] && rm -R ../../../v0.9.7
|
||||||
|
[ -e ../../../v0.9.12 ] && rm -R ../../../v0.9.12
|
||||||
|
|
||||||
|
# Install from binary
|
||||||
|
nvm install 0.9.7
|
||||||
|
nvm i 0.9.12
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d ../../../v0.9.7 ]
|
||||||
|
[ -d ../../../v0.9.12 ]
|
||||||
|
|
||||||
|
# Use the first one
|
||||||
|
nvm use 0.9.7
|
||||||
|
|
||||||
|
# Use the latest one
|
||||||
|
nvm use 0.9
|
||||||
|
node --version | grep v0.9.12
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
NVM_TEST_VERSION=v0.10.7
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
||||||
|
|
||||||
|
# Install from binary
|
||||||
|
cat "$NVM_TEST_VERSION" > .nvmrc
|
||||||
|
|
||||||
|
nvm install
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d ../../../$NVM_TEST_VERSION ]
|
||||||
|
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
NVM_TEST_VERSION=v0.10.7
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
||||||
|
|
||||||
|
# Install from binary
|
||||||
|
cat "$NVM_TEST_VERSION" > .nvmrc
|
||||||
|
|
||||||
|
nvm install -s
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d ../../../$NVM_TEST_VERSION ]
|
||||||
|
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION
|
||||||
|
|
||||||
|
|
||||||
6
test/slow/nvm install/setup_dir
Executable file
6
test/slow/nvm install/setup_dir
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ -f ".nvmrc" ]; then
|
||||||
|
mv .nvmrc .nvmrc.bak
|
||||||
|
fi
|
||||||
|
|
||||||
13
test/slow/nvm install/teardown_dir
Executable file
13
test/slow/nvm install/teardown_dir
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
nvm uninstall v0.10.7
|
||||||
|
|
||||||
|
if [ -f ".nvmrc" ]; then
|
||||||
|
rm .nvmrc
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f ".nvmrc.bak" ]; then
|
||||||
|
mv .nvmrc.bak .nvmrc
|
||||||
|
fi
|
||||||
|
|
||||||
9
test/slow/nvm run/Running "nvm run 0.x" should work
Executable file
9
test/slow/nvm run/Running "nvm run 0.x" should work
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
[ "$(nvm run 0.10.7 --version | tail -1)" = "v0.10.7" ] || die "`nvm run` failed to run with the correct version"
|
||||||
|
|
||||||
13
test/slow/nvm run/Running "nvm run" should pick up .nvmrc version
Executable file
13
test/slow/nvm run/Running "nvm run" should pick up .nvmrc version
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
echo "0.10.7" > .nvmrc
|
||||||
|
|
||||||
|
[ "$(nvm run --version | tail -1)" = "v0.10.7" ] || die "\`nvm run\` failed to run with the .nvmrc version"
|
||||||
|
|
||||||
|
[ "$(nvm run --version | head -1)" = "Found '$PWD/.nvmrc' with version <0.10.7>" ] || die "\`nvm run\` failed to print out the \"found in .nvmrc\" message"
|
||||||
|
|
||||||
9
test/slow/nvm run/setup_dir
Executable file
9
test/slow/nvm run/setup_dir
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
nvm install 0.10.7
|
||||||
|
|
||||||
|
if [ -f ".nvmrc" ]; then
|
||||||
|
mv .nvmrc .nvmrc.bak
|
||||||
|
fi
|
||||||
|
|
||||||
11
test/slow/nvm run/teardown_dir
Executable file
11
test/slow/nvm run/teardown_dir
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
nvm uninstall v0.10.7
|
||||||
|
|
||||||
|
rm .nvmrc
|
||||||
|
|
||||||
|
if [ -f ".nvmrc.bak" ]; then
|
||||||
|
mv .nvmrc.bak .nvmrc
|
||||||
|
fi
|
||||||
|
|
||||||
23
uninstall.sh
23
uninstall.sh
@@ -1,23 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
|
|
||||||
has=$(cat ~/.bashrc | egrep "^# ADDED BY npm FOR NVM$" || true)
|
|
||||||
if [ "x$has" == "x" ]; then
|
|
||||||
echo "doesn't have it, exiting"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
tmp=~/.bashrc.tmp
|
|
||||||
cat ~/.bashrc | {
|
|
||||||
incode=0
|
|
||||||
while read line; do
|
|
||||||
if [ "$line" == "# ADDED BY npm FOR NVM" ]; then
|
|
||||||
incode=1
|
|
||||||
elif [ "$line" == "# END ADDED BY npm FOR NVM" ] \
|
|
||||||
&& [ $incode -eq 1 ]; then
|
|
||||||
incode=0
|
|
||||||
elif [ $incode -eq 0 ]; then
|
|
||||||
echo "$line" >> $tmp
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
mv $tmp ~/.bashrc
|
|
||||||
Reference in New Issue
Block a user