Created
February 16, 2020 12:13
-
-
Save juanpicado/42a856c3ce027bfaf31f9578230c2e4a to your computer and use it in GitHub Desktop.
Verdaccio and Node API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const path = require('path'); | |
const verdaccio = require('verdaccio').default; | |
const YAML = require('js-yaml'); | |
const getConfig = () => { | |
return YAML.safeLoad(fs.readFileSync(path.join(__dirname, 'config.yaml'), 'utf8')); | |
} | |
const cache = path.join(__dirname, 'cache'); | |
const config = Object.assign({}, getConfig(), { | |
self_path: cache | |
}); | |
verdaccio(config, 6000, cache, '1.0.0', 'verdaccio', | |
(webServer, addrs, pkgName, pkgVersion) => { | |
try { | |
webServer.unref(); | |
webServer.listen(addrs.port || addrs.path, addrs.host, () => { | |
console.log('verdaccio running'); | |
}); | |
} catch (error) { | |
console.error(error); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment