UNPKG

node-publisher

Version:

A configurable release automation tool inspired by create-react-app and Travis CI.

42 lines (33 loc) 848 B
const fs = require('fs'); const path = require('path'); const { LERNA_JSON_PATH } = require('../constants'); const { isYarnBerry } = require('../yarn'); const npmClient = () => { const clientMap = { 'package-lock.json': 'npm', 'yarn.lock': 'yarn' }; let client; for (const file in clientMap) { if (fs.existsSync(path.resolve(process.env.PWD, file))) { client = clientMap[file]; } } if (client === 'yarn' && isYarnBerry()) { client = 'yarn-berry'; } if (!client) { throw new Error( 'Client could not be detected, make sure you use one of the supported clients.' ); } return client; }; const publishClient = () => { const lernaConfigExists = fs.existsSync(LERNA_JSON_PATH); return lernaConfigExists ? 'lerna' : npmClient(); }; module.exports = { npmClient, publishClient };