Fix file path issue.
This commit is contained in:
@@ -1,20 +1,21 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function batchAccounts(accounts, batchSize) {
|
||||
const sortedDir = '../accounts/sorted';
|
||||
if (!fs.existsSync(sortedDir)) {
|
||||
fs.mkdirSync(sortedDir);
|
||||
if (!fs.existsSync(path.join(__dirname, sortedDir))) {
|
||||
fs.mkdirSync(path.join(__dirname, sortedDir));
|
||||
}
|
||||
|
||||
for (let i = 0; i < accounts.length; i += batchSize) {
|
||||
const batch = accounts.slice(i, i + batchSize);
|
||||
const batchNumber = Math.ceil((i + 1) / batchSize);
|
||||
const batchFilename = `${sortedDir}/batch${batchNumber}.json`;
|
||||
fs.writeFileSync(batchFilename, JSON.stringify(batch, null, 2));
|
||||
fs.writeFileSync(path.join(__dirname, batchFilename), JSON.stringify(batch, null, 2));
|
||||
}
|
||||
}
|
||||
|
||||
const accounts = require('../accounts/accounts.json');
|
||||
const accounts = require(path.join(__dirname, '../accounts/accounts.json'));
|
||||
batchAccounts(accounts, 6);
|
||||
|
||||
module.exports = { batchAccounts };
|
||||
@@ -1,4 +1,5 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { By, Key, until } = require('selenium-webdriver');
|
||||
|
||||
const { createIdentity } = require('./identityHandler');
|
||||
@@ -100,13 +101,13 @@ async function createAccount(driver) {
|
||||
|
||||
|
||||
let accounts = [];
|
||||
if (fs.existsSync('../accounts/accounts.json')) {
|
||||
if (fs.existsSync(path.join(__dirname, '../accounts/accounts.json'))) {
|
||||
const content = fs.readFileSync('accounts.json', 'utf8');
|
||||
accounts = JSON.parse(content);
|
||||
}
|
||||
|
||||
accounts.push(account);
|
||||
fs.writeFileSync('../accounts/accounts.json', JSON.stringify(accounts));
|
||||
fs.writeFileSync(path.join(__dirname, '../accounts/accounts.json'), JSON.stringify(accounts));
|
||||
|
||||
console.log('Account saved to accounts.json, there are currently ' + accounts.length + ' accounts');
|
||||
|
||||
|
||||
11
package-lock.json
generated
11
package-lock.json
generated
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "accountCreator",
|
||||
"name": "mcr-account-creator-bot",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
@@ -7,6 +7,7 @@
|
||||
"dependencies": {
|
||||
"bluebird": "^3.7.2",
|
||||
"cron": "^2.3.0",
|
||||
"dotenv": "^16.0.3",
|
||||
"faker": "^6.6.6",
|
||||
"imap": "^0.8.19",
|
||||
"mail-listener2": "^0.3.1",
|
||||
@@ -430,6 +431,14 @@
|
||||
"url": "https://github.com/fb55/domutils?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "16.0.3",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
|
||||
"integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/encoding": {
|
||||
"version": "0.1.13",
|
||||
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"dependencies": {
|
||||
"bluebird": "^3.7.2",
|
||||
"cron": "^2.3.0",
|
||||
"dotenv": "^16.0.3",
|
||||
"faker": "^6.6.6",
|
||||
"imap": "^0.8.19",
|
||||
"mail-listener2": "^0.3.1",
|
||||
|
||||
Reference in New Issue
Block a user