mirror of
https://github.com/JustusPlays78/SectorFileUpdater.git
synced 2025-07-04 07:45:15 +00:00
added install creds, fixed inserts into files
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
function searchAndAppend(dir, data) {
|
||||
let filesAppended = [];
|
||||
|
||||
function searchAndAppendCredentials(dir, data) {
|
||||
var stringToAppend = `LastSession connecttype 0\nLastSession realname ${data[0]}\nLastSession certificate ${data[1]}\nLastSession password ${data[2]}\nLastSession rating ${data[3]}\nLastSession server AMSTERDAM\nLastSession tovatsim 1\n`;
|
||||
fs.readdir(dir, (err, files) => {
|
||||
if (err) throw err;
|
||||
@ -12,10 +14,11 @@ function searchAndAppend(dir, data) {
|
||||
fs.readFile(filepath, 'utf8', (err, data) => {
|
||||
if (err) throw err;
|
||||
const lastLine = data.split('\n').slice(-2)[0];
|
||||
if (lastLine !== stringToAppend.split('\n').slice(-2)[0]) {
|
||||
if (lastLine !== stringToAppend.split('\n').slice(-2)[0] && !filesAppended.includes(filepath)) {
|
||||
fs.appendFile(filepath, stringToAppend, (err) => {
|
||||
if (err) throw err;
|
||||
console.log(`The following lines were appended to ${filepath}`);
|
||||
// console.log(`The following lines were appended to ${filepath}`);
|
||||
filesAppended.push(filepath);
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -23,4 +26,30 @@ function searchAndAppend(dir, data) {
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function searchAndInsertHoppie(directory) {
|
||||
let files = [];
|
||||
const targetFile = "TopSkyCPDLChoppieCode.txt";
|
||||
|
||||
function searchDir(dir) {
|
||||
fs.readdirSync(dir).forEach(file => {
|
||||
const filePath = path.join(dir, file);
|
||||
const stat = fs.statSync(filePath);
|
||||
if (stat.isDirectory()) {
|
||||
search(filePath);
|
||||
} else if (file === targetFile) {
|
||||
files.push(filePath);
|
||||
}
|
||||
});
|
||||
}
|
||||
search(directory);
|
||||
|
||||
files.forEach(file => {
|
||||
fs.writeFileSync(file, passwordhoppieInput.value, (err) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user