Skip to content

Commit

Permalink
fix: Fix search assets path resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed Oct 23, 2024
1 parent 985c93a commit 0b22281
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
3 changes: 1 addition & 2 deletions scripts/build.cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const SEARCH_LANGS = require.resolve('@diplodoc/search-extension/worker/langs');
const CLIENT_PATH = dirname(require.resolve('@diplodoc/client/manifest'));
const ASSETS_PATH = resolve(__dirname, '..', 'assets');

// TODO: link with constants
const SEARCH_API_OUTPUT = join(ASSETS_PATH, 'search', 'index.js');
const SEARCH_LANGS_OUTPUT = join(ASSETS_PATH, 'search', 'langs');

Expand Down Expand Up @@ -38,8 +39,6 @@ const commonConfig = {
],
define: {
VERSION: JSON.stringify(version),
SEARCH_API: JSON.stringify(SEARCH_API_OUTPUT),
SEARCH_LANGS: JSON.stringify(SEARCH_LANGS_OUTPUT),
},
};

Expand Down
4 changes: 3 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {resolve} from 'path';
import {join, resolve} from 'node:path';
import {platform} from 'process';
const os = require('os');
const notes = require('@diplodoc/transform/lib/plugins/notes');
Expand Down Expand Up @@ -38,6 +38,8 @@ export const LINT_CONFIG_FILENAME = '.yfmlint';
export const SINGLE_PAGE_FILENAME = 'single-page.html';
export const SINGLE_PAGE_DATA_FILENAME = 'single-page.json';
export const CUSTOM_STYLE = 'custom-style';
export const SEARCH_API = join(ASSETS_FOLDER, 'search', 'index.js');
export const SEARCH_LANGS = join(ASSETS_FOLDER, 'search', 'langs');

export enum Stage {
NEW = 'new',
Expand Down
2 changes: 0 additions & 2 deletions src/globals.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
declare const VERSION: string;
declare const SEARCH_API: string;
declare const SEARCH_LANGS: string;

type Hash<T = any> = Record<string, T>;
2 changes: 2 additions & 0 deletions src/services/search.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type {DocInnerProps, DocPageData} from '@diplodoc/client';
import type {Lang} from '../constants';

import {SEARCH_API, SEARCH_LANGS} from '../constants';

import {join} from 'node:path';
import {mkdirSync, writeFileSync} from 'node:fs';

Expand Down
3 changes: 1 addition & 2 deletions tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
"~/*": ["../src/*"]
},
"types": ["node", "jest"]
},
"include": ["../src/globals.d.ts"]
}
}

0 comments on commit 0b22281

Please sign in to comment.