Skip to content

Instantly share code, notes, and snippets.

@juanpicado
Created February 16, 2020 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanpicado/42a856c3ce027bfaf31f9578230c2e4a to your computer and use it in GitHub Desktop.
Save juanpicado/42a856c3ce027bfaf31f9578230c2e4a to your computer and use it in GitHub Desktop.
Verdaccio and Node API
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