aboutsummaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorHysterelius2024-07-22 01:03:44 +1000
committerGitHub2024-07-21 08:03:44 -0700
commit7abdb6b15a2683a97f6fbc25149ea2ea4c8846f7 (patch)
tree53213faeed8b34f835bf10f7e77b3f4c69901f34 /static
parenta7244a2983538f373c0af2ecfa4d6377584b8063 (diff)
downloadabridge-7abdb6b15a2683a97f6fbc25149ea2ea4c8846f7.tar.gz
abridge-7abdb6b15a2683a97f6fbc25149ea2ea4c8846f7.tar.bz2
abridge-7abdb6b15a2683a97f6fbc25149ea2ea4c8846f7.zip
Bump replace-in-file (#182)
* Update replace-in-file * Fix npm bugs * Fix npm bugs v2
Diffstat (limited to 'static')
-rw-r--r--static/js/searchChange.js23
1 files changed, 11 insertions, 12 deletions
diff --git a/static/js/searchChange.js b/static/js/searchChange.js
index afe3214..8f776ae 100644
--- a/static/js/searchChange.js
+++ b/static/js/searchChange.js
@@ -1,11 +1,10 @@
const fs = require('fs');
const path = require("path");
-const replace = require('replace-in-file');
-
// Path for config.toml
const configTomlPath = path.join(__dirname, "../../config.toml");
async function main() {
+ const { replaceInFileSync } = await import('replace-in-file');
// Process arguments to determine the search mode
const args = process.argv.slice(2); // Remove the first two default arguments
@@ -14,11 +13,11 @@ async function main() {
switch (args[0]) {
case '--pagefind':
console.log('Pagefind search mode activated.');
- await swapToPagefind();
+ await swapToPagefind(replaceInFileSync);
break;
case '--elasticlunr':
console.log('Elasticlunr search mode activated.');
- await swapToElasticlunr();
+ await swapToElasticlunr(replaceInFileSync);
break;
default:
console.log('Unknown search mode. Please use --pagefind or --elasticlunr.');
@@ -30,38 +29,38 @@ async function main() {
main();
-async function swapToPagefind() {
+async function swapToPagefind(replaceInFileSync) {
// Edit the config.toml file
- replace.sync({
+ replaceInFileSync({
files: configTomlPath,
from: /search_library = ['|"]\w+['|"]/g,
to: 'search_library = "pagefind"',
});
- replace.sync({
+ replaceInFileSync({
files: configTomlPath,
from: /online_indexformat = ['|"]\w+['|"]/g,
to: 'online_indexformat = "fuse_json"',
});
- replace.sync({
+ replaceInFileSync({
files: configTomlPath,
from: /index_format = ['|"]\w+['|"]/g,
to: 'index_format = "fuse_json"',
});
}
-async function swapToElasticlunr() {
+async function swapToElasticlunr(replaceInFileSync) {
// Edit the config.toml file
- replace.sync({
+ replaceInFileSync({
files: configTomlPath,
from: /search_library = ['|"]\w+['|"]/g,
to: 'search_library = "elasticlunr"',
});
- replace.sync({
+ replaceInFileSync({
files: configTomlPath,
from: /online_indexformat = ['|"]\w+['|"]/g,
to: 'online_indexformat = "elasticlunr_json"',
});
- replace.sync({
+ replaceInFileSync({
files: configTomlPath,
from: /index_format = ['|"]\w+['|"]/g,
to: 'index_format = "elasticlunr_json"',