Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
🔨 Move 'config' directory into 'src' directory
Browse files Browse the repository at this point in the history
  • Loading branch information
sameersubudhi committed Nov 1, 2023
1 parent 18c5964 commit bcdd19c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const getConfig = async (

export const resolveConfigPathByNetworkID = async (networkIdentifier: string): Promise<string> => {
const network = NETWORK_CONSTANT[networkIdentifier].name;
const configFilePath = join(__dirname, '../..', `config/${network}/config.json`);
const configFilePath = join(__dirname, '..', `constants/config/${network}/config.json`);
return configFilePath;
};

Expand Down
6 changes: 3 additions & 3 deletions src/utils/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ const copyLegacyDB = async (_this: Command) => {

export const getFinalConfigPath = async (outputDir: string, network: string) =>
(await exists(`${outputDir}/config.json`))
? outputDir
: path.resolve(__dirname, '../..', 'config', network);
? path.resolve(outputDir, 'config.json')
: path.resolve(__dirname, '..', 'constants/config', network, 'config.json');

export const validateStartCommandFlags = async (
allowedFlags: string[],
Expand Down Expand Up @@ -149,7 +149,7 @@ const resolveLiskCoreStartCommand = async (_this: Command, network: string, conf
const baseStartCommand = `lisk-core start --network ${network}`;

if (!isUserConfirmed) {
const defaultStartCommand = `${baseStartCommand} --config ${configPath}/config.json`;
const defaultStartCommand = `${baseStartCommand} --config ${configPath}`;
liskCoreStartCommand = defaultStartCommand;
return defaultStartCommand;
}
Expand Down
4 changes: 3 additions & 1 deletion test/unit/utils/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ describe('Test networkIdentifier method', () => {

describe('Test resolveConfigPathByNetworkID method', () => {
it('should resolve config filePath when called by valid networkID', async () => {
const expectedConfigPath = resolve(`${__dirname}../../../../config/testnet/config.json`);
const expectedConfigPath = resolve(
`${__dirname}../../../../src/constants/config/testnet/config.json`,
);
const networkID = '15f0dacc1060e91818224a94286b13aa04279c640bd5d6f193182031d133df7c';
const configPath = await resolveConfigPathByNetworkID(networkID);
expect(configPath).toBe(expectedConfigPath);
Expand Down
12 changes: 10 additions & 2 deletions test/unit/utils/node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,23 @@ describe('Test getFinalConfigPath method', () => {
const outputDir = join(__dirname, '../../..', 'test/unit/fixtures/outputDir');
const configPath = await getFinalConfigPath(outputDir, network);

const expectedResponse = join(__dirname, '../../..', 'config/mainnet');
const expectedResponse = join(
__dirname,
'../../..',
'src/constants/config/mainnet/config.json',
);
expect(configPath).toBe(expectedResponse);
});

it('should return correct config filepath when output directory exists', async () => {
const outputDir = join(__dirname, '../../..', 'config');
const configPath = await getFinalConfigPath(outputDir, network);

const expectedResponse = join(__dirname, '../../..', 'config/mainnet');
const expectedResponse = join(
__dirname,
'../../..',
'src/constants/config/mainnet/config.json',
);
expect(configPath).toBe(expectedResponse);
});
});
Expand Down

0 comments on commit bcdd19c

Please sign in to comment.