Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
veeramarni committed Nov 9, 2022
1 parent 07e8c6b commit 25481e6
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions tools/update-dependency-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const path = require('path');
const fs = require('fs');

const SERVER_FOLDER = './servers';
const simpleGit = require('simple-git/promise');
const simpleGit = require('simple-git');

const git = simpleGit();

Expand All @@ -32,24 +32,30 @@ const searchAndUpdate = (dependencies, filePath, obj) => {
try {
fs.readdirSync(dependencyFolder);
} catch (err) {

console.log(`--- err ${err.message}`);
console.log(
`--- err Search for dependency of ${filePath} with package path ${relativeDepFolder} not found`,
`err Search for dependency of ${filePath} with package path ${relativeDepFolder} not found`,
);
console.log(`--- err ${err.message}`);
return;
throw err;
}
glob(`${dependencyFolder}/package.json`, null, (err, files) => {
if (err) return console.error(`Unable to scan directory: ${err}`);
console.log(files);
files.forEach((file) => {
fs.readFile(file, 'utf-8', (err, data) => {
if (err) return console.error(`Unable to scan directory: ${err}`);

try {
const objVersion = JSON.parse(data);
const { version } = objVersion;
dependencies[key] = `${version}`;
const str = JSON.stringify(obj, null, 2);
fs.writeFileSync(fileWrie, str, 'ascii');
} catch(err) {
console.error(`Failed at file: ${file}`)
throw(err);
}

});
});
});
Expand Down Expand Up @@ -89,8 +95,10 @@ glob(
git.commit('corrected packages version!');
} else console.log('no change');
})
.catch((err) => console.error(err));
.catch((err) => {
console.error(err);
});
})
.catch((err) => console.error(err));
},
);
);

0 comments on commit 25481e6

Please sign in to comment.