mirror of
https://github.com/hanzoai/workbox.git
synced 2026-09-24 17:04:35 +00:00
30 lines
724 B
JavaScript
30 lines
724 B
JavaScript
/*
|
|
Copyright 2018 Google LLC
|
|
|
|
Use of this source code is governed by an MIT-style
|
|
license that can be found in the LICENSE file or at
|
|
https://opensource.org/licenses/MIT.
|
|
*/
|
|
|
|
const {globSync} = require('glob');
|
|
const path = require('path');
|
|
|
|
const DEFAULT_ROOT = path.join(__dirname, '..', '..');
|
|
|
|
const getPackages = ({type, root = DEFAULT_ROOT} = {}) => {
|
|
const pathToPkgJsons = globSync('packages/*/package.json', {cwd: root});
|
|
|
|
return pathToPkgJsons
|
|
.map((pathToPkgJson) => {
|
|
const pkg = require(`${path.resolve(root)}/${pathToPkgJson}`);
|
|
return pkg;
|
|
})
|
|
.filter((pkg) => {
|
|
return pkg.workbox && pkg.workbox.packageType === type;
|
|
});
|
|
};
|
|
|
|
module.exports = {
|
|
getPackages,
|
|
};
|