Removed glob dependencies
This commit is contained in:
parent
dcaac29eb2
commit
78d4f91b0f
|
@ -27,7 +27,7 @@ jobs:
|
|||
run: wget https://raw.githubusercontent.com/pnp/sp-dev-fx-extensions/main/.metadata/samples.json
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install glob lodash
|
||||
run: npm install lodash
|
||||
|
||||
- name: Merge JSON files
|
||||
run: node .github/workflows/merge.js
|
||||
|
|
|
@ -1,14 +1,27 @@
|
|||
const glob = require('glob');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const _ = require('lodash');
|
||||
|
||||
let result = {};
|
||||
|
||||
glob("samples/**/assets/sample.json", function (er, files) {
|
||||
files.forEach(file => {
|
||||
const data = JSON.parse(fs.readFileSync(file));
|
||||
result = _.merge(result, data);
|
||||
});
|
||||
function getDirectories(path) {
|
||||
return fs.readdirSync(path, { withFileTypes: true })
|
||||
.filter(dirent => dirent.isDirectory())
|
||||
.map(dirent => dirent.name);
|
||||
}
|
||||
|
||||
fs.writeFileSync('samples.json', JSON.stringify(result));
|
||||
let directories = getDirectories('samples');
|
||||
directories.forEach(directory => {
|
||||
let assetsPath = path.join('samples', directory, 'assets');
|
||||
if (fs.existsSync(assetsPath)) {
|
||||
let files = fs.readdirSync(assetsPath);
|
||||
files.forEach(file => {
|
||||
if (file === 'sample.json') {
|
||||
let data = JSON.parse(fs.readFileSync(path.join(assetsPath, file)));
|
||||
result = _.merge(result, data);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
fs.writeFileSync('samples.json', JSON.stringify(result));
|
Loading…
Reference in New Issue