mirror of
https://github.com/primer/css.git
synced 2024-12-19 20:21:38 +03:00
36 lines
929 B
JavaScript
Executable File
36 lines
929 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
const fs = require('fs')
|
|
const globby = require('globby')
|
|
const {join} = require('path')
|
|
|
|
const getPackages = (debug = false) => {
|
|
const lernaConfig = require('../lerna.json')
|
|
const packageGlobs = lernaConfig.packages.concat('!**/*.md')
|
|
return globby(packageGlobs)
|
|
.then(packagePaths => {
|
|
if (debug) {
|
|
console.warn(`Filtering ${packagePaths.length} paths...`)
|
|
}
|
|
return packagePaths.filter(pkg => {
|
|
try {
|
|
require.resolve(join('..', pkg, 'package.json'))
|
|
return true
|
|
} catch (error) {
|
|
if (debug) {
|
|
console.warn(`No package.json in ${pkg}: ${error}`)
|
|
}
|
|
return false
|
|
}
|
|
})
|
|
})
|
|
}
|
|
|
|
if (module.parent) {
|
|
module.exports = getPackages
|
|
} else {
|
|
getPackages(true).then(packages => {
|
|
console.warn('%d packages:', packages.length)
|
|
packages.forEach(pkg => console.log(pkg))
|
|
})
|
|
}
|