forked from necccc/npm-migrate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
npm-migrate.js
39 lines (32 loc) · 1.19 KB
/
npm-migrate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const mute = require('mute')
const npm = require('npm')
const curry = require('lodash.curry')
const { unpack, pack } = require('./tgz')
const cleanup = require('./cleanup')
const { getVersionList, getTarballs, publishSeries } = require('./npm_utils')
const updatePackage = require('./update')
module.exports = function (moduleName, oldRegistry, newRegistry, options = { debug: false }) {
if (!options.debug) {
var unmute = mute()
}
let curried_updatePackage = curry(updatePackage)
curried_updatePackage = curried_updatePackage(newRegistry)
let curried_getTarballs = curry(getTarballs)
curried_getTarballs = curried_getTarballs(moduleName, oldRegistry)
let curried_publishSeries = curry(publishSeries)
curried_publishSeries = curried_publishSeries(newRegistry)
return getVersionList(moduleName, oldRegistry, newRegistry)
.then(curried_getTarballs)
.then(unpack)
.then(curried_updatePackage)
.then(pack)
.then(curried_publishSeries)
.then(cleanup)
.then((results) => {
if (unmute) unmute();
return results
})
.catch((err) => {
console.error(err)
})
}