1
1
mirror of https://github.com/primer/css.git synced 2024-12-11 11:16:04 +03:00
css/script/revert-packages
2017-10-10 11:41:41 -07:00

31 lines
823 B
JavaScript
Executable File

#!/usr/bin/env node
const execa = require('execa')
const fse = require('fs-extra')
const globby = require('globby')
const revertPackages = () => {
const lernaConfig = require('../lerna.json')
const globs = lernaConfig.packages
const jsons = globs.map(glob => glob + '/package.json')
const tarballs = globs.map(glob => glob + '/*.tgz')
const opts = {stdio: 'inherit'}
return Promise.all([
execa('git', ['checkout', '--'].concat(globs), opts),
globby(tarballs)
.then(paths => {
if (paths.length) {
console.warn('deleting %d tarball(s)', paths.length)
return Promise.all(
paths.map(tgz => fse.remove(tgz))
)
}
}),
])
}
if (module.parent) {
module.exports = revertPackages
} else {
revertPackages().then(() => process.exit(0))
}