bin scripts: Promisify npm.load
parent
92cd2cc760
commit
efdcaae526
|
@ -7,11 +7,14 @@
|
||||||
// unhandled rejection into an uncaught exception, which does cause Node.js to exit.
|
// unhandled rejection into an uncaught exception, which does cause Node.js to exit.
|
||||||
process.on('unhandledRejection', (err) => { throw err; });
|
process.on('unhandledRejection', (err) => { throw err; });
|
||||||
|
|
||||||
|
const npm = require('ep_etherpad-lite/node_modules/npm');
|
||||||
|
const util = require('util');
|
||||||
|
|
||||||
if (process.argv.length !== 2) throw new Error('Use: node bin/checkAllPads.js');
|
if (process.argv.length !== 2) throw new Error('Use: node bin/checkAllPads.js');
|
||||||
|
|
||||||
// load and initialize NPM
|
(async () => {
|
||||||
const npm = require('ep_etherpad-lite/node_modules/npm');
|
await util.promisify(npm.load)({});
|
||||||
npm.load({}, async () => {
|
|
||||||
try {
|
try {
|
||||||
// initialize the database
|
// initialize the database
|
||||||
require('ep_etherpad-lite/node/utils/Settings');
|
require('ep_etherpad-lite/node/utils/Settings');
|
||||||
|
@ -92,4 +95,4 @@ npm.load({}, async () => {
|
||||||
console.trace(err);
|
console.trace(err);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
});
|
})();
|
||||||
|
|
|
@ -7,15 +7,18 @@
|
||||||
// unhandled rejection into an uncaught exception, which does cause Node.js to exit.
|
// unhandled rejection into an uncaught exception, which does cause Node.js to exit.
|
||||||
process.on('unhandledRejection', (err) => { throw err; });
|
process.on('unhandledRejection', (err) => { throw err; });
|
||||||
|
|
||||||
|
const npm = require('ep_etherpad-lite/node_modules/npm');
|
||||||
|
const util = require('util');
|
||||||
|
|
||||||
if (process.argv.length !== 3) throw new Error('Use: node bin/checkPad.js $PADID');
|
if (process.argv.length !== 3) throw new Error('Use: node bin/checkPad.js $PADID');
|
||||||
|
|
||||||
// get the padID
|
// get the padID
|
||||||
const padId = process.argv[2];
|
const padId = process.argv[2];
|
||||||
let checkRevisionCount = 0;
|
let checkRevisionCount = 0;
|
||||||
|
|
||||||
// load and initialize NPM;
|
(async () => {
|
||||||
const npm = require('ep_etherpad-lite/node_modules/npm');
|
await util.promisify(npm.load)({});
|
||||||
npm.load({}, async () => {
|
|
||||||
try {
|
try {
|
||||||
// initialize database
|
// initialize database
|
||||||
require('ep_etherpad-lite/node/utils/Settings');
|
require('ep_etherpad-lite/node/utils/Settings');
|
||||||
|
@ -86,4 +89,4 @@ npm.load({}, async () => {
|
||||||
console.trace(err);
|
console.trace(err);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
});
|
})();
|
||||||
|
|
|
@ -12,12 +12,14 @@ if (process.argv.length !== 3) throw new Error('Use: node bin/checkPadDeltas.js
|
||||||
// get the padID
|
// get the padID
|
||||||
const padId = process.argv[2];
|
const padId = process.argv[2];
|
||||||
|
|
||||||
// load and initialize NPM;
|
|
||||||
const expect = require('../tests/frontend/lib/expect');
|
const expect = require('../tests/frontend/lib/expect');
|
||||||
const diff = require('ep_etherpad-lite/node_modules/diff');
|
const diff = require('ep_etherpad-lite/node_modules/diff');
|
||||||
const npm = require('ep_etherpad-lite/node_modules/npm');
|
const npm = require('ep_etherpad-lite/node_modules/npm');
|
||||||
|
const util = require('util');
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
await util.promisify(npm.load)({});
|
||||||
|
|
||||||
npm.load({}, async () => {
|
|
||||||
// initialize database
|
// initialize database
|
||||||
require('ep_etherpad-lite/node/utils/Settings');
|
require('ep_etherpad-lite/node/utils/Settings');
|
||||||
const db = require('ep_etherpad-lite/node/db/DB');
|
const db = require('ep_etherpad-lite/node/db/DB');
|
||||||
|
@ -102,4 +104,4 @@ npm.load({}, async () => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
})();
|
||||||
|
|
|
@ -16,9 +16,10 @@ if (process.argv.length !== 3) throw new Error('Use: node extractPadData.js $PAD
|
||||||
const padId = process.argv[2];
|
const padId = process.argv[2];
|
||||||
|
|
||||||
const npm = require('ep_etherpad-lite/node_modules/npm');
|
const npm = require('ep_etherpad-lite/node_modules/npm');
|
||||||
|
const util = require('util');
|
||||||
|
|
||||||
npm.load({}, async (err) => {
|
(async () => {
|
||||||
if (err) throw err;
|
await util.promisify(npm.load)({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// initialize database
|
// initialize database
|
||||||
|
@ -29,7 +30,6 @@ npm.load({}, async (err) => {
|
||||||
// load extra modules
|
// load extra modules
|
||||||
const dirtyDB = require('ep_etherpad-lite/node_modules/dirty');
|
const dirtyDB = require('ep_etherpad-lite/node_modules/dirty');
|
||||||
const padManager = require('ep_etherpad-lite/node/db/PadManager');
|
const padManager = require('ep_etherpad-lite/node/db/PadManager');
|
||||||
const util = require('util');
|
|
||||||
|
|
||||||
// initialize output database
|
// initialize output database
|
||||||
const dirty = dirtyDB(`${padId}.db`);
|
const dirty = dirtyDB(`${padId}.db`);
|
||||||
|
@ -71,4 +71,4 @@ npm.load({}, async (err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
});
|
})();
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
// unhandled rejection into an uncaught exception, which does cause Node.js to exit.
|
// unhandled rejection into an uncaught exception, which does cause Node.js to exit.
|
||||||
process.on('unhandledRejection', (err) => { throw err; });
|
process.on('unhandledRejection', (err) => { throw err; });
|
||||||
|
|
||||||
|
const npm = require('ep_etherpad-lite/node_modules/npm');
|
||||||
|
const util = require('util');
|
||||||
|
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
|
|
||||||
const log = (str) => {
|
const log = (str) => {
|
||||||
|
@ -43,10 +46,10 @@ const unescape = (val) => {
|
||||||
return val;
|
return val;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
await util.promisify(npm.load)({});
|
||||||
|
|
||||||
require('ep_etherpad-lite/node_modules/npm').load({}, (er, npm) => {
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const ueberDB = require('ep_etherpad-lite/node_modules/ueberdb2');
|
const ueberDB = require('ep_etherpad-lite/node_modules/ueberdb2');
|
||||||
const settings = require('ep_etherpad-lite/node/utils/Settings');
|
const settings = require('ep_etherpad-lite/node/utils/Settings');
|
||||||
const log4js = require('ep_etherpad-lite/node_modules/log4js');
|
const log4js = require('ep_etherpad-lite/node_modules/log4js');
|
||||||
|
@ -106,4 +109,4 @@ require('ep_etherpad-lite/node_modules/npm').load({}, (er, npm) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
})();
|
||||||
|
|
|
@ -4,9 +4,12 @@
|
||||||
// unhandled rejection into an uncaught exception, which does cause Node.js to exit.
|
// unhandled rejection into an uncaught exception, which does cause Node.js to exit.
|
||||||
process.on('unhandledRejection', (err) => { throw err; });
|
process.on('unhandledRejection', (err) => { throw err; });
|
||||||
|
|
||||||
|
const npm = require('ep_etherpad-lite/node_modules/npm');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
|
|
||||||
require('ep_etherpad-lite/node_modules/npm').load({}, async (er, npm) => {
|
(async () => {
|
||||||
|
await util.promisify(npm.load)({});
|
||||||
|
|
||||||
process.chdir(`${npm.root}/..`);
|
process.chdir(`${npm.root}/..`);
|
||||||
|
|
||||||
// This script requires that you have modified your settings.json file
|
// This script requires that you have modified your settings.json file
|
||||||
|
@ -56,4 +59,4 @@ require('ep_etherpad-lite/node_modules/npm').load({}, async (er, npm) => {
|
||||||
|
|
||||||
await util.promisify(db.close.bind(db))();
|
await util.promisify(db.close.bind(db))();
|
||||||
console.log('Finished.');
|
console.log('Finished.');
|
||||||
});
|
})();
|
||||||
|
|
|
@ -18,8 +18,10 @@ const padId = process.argv[2];
|
||||||
let valueCount = 0;
|
let valueCount = 0;
|
||||||
|
|
||||||
const npm = require('ep_etherpad-lite/node_modules/npm');
|
const npm = require('ep_etherpad-lite/node_modules/npm');
|
||||||
npm.load({}, async (err) => {
|
const util = require('util');
|
||||||
if (err) throw err;
|
|
||||||
|
(async () => {
|
||||||
|
await util.promisify(npm.load)({});
|
||||||
|
|
||||||
// intialize database
|
// intialize database
|
||||||
require('ep_etherpad-lite/node/utils/Settings');
|
require('ep_etherpad-lite/node/utils/Settings');
|
||||||
|
@ -56,4 +58,4 @@ npm.load({}, async (err) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
console.info(`Finished: Replaced ${valueCount} values in the database`);
|
console.info(`Finished: Replaced ${valueCount} values in the database`);
|
||||||
});
|
})();
|
||||||
|
|
Loading…
Reference in New Issue