Skip to content

Commit

Permalink
Merge pull request #2142 from OriginTrail/v6/develop
Browse files Browse the repository at this point in the history
update migration folder path (#2141)
  • Loading branch information
zeroxbt authored Oct 20, 2022
2 parents 4d304d1 + 7510639 commit 2f6317b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/migration/network-private-key-migration.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { join } from 'path';
import appRootPath from 'app-root-path';
import { mkdir, writeFile } from 'fs/promises';
import BaseMigration from './base-migration.js';
import { LIBP2P_KEY_DIRECTORY, LIBP2P_KEY_FILENAME } from '../constants/constants.js';
Expand All @@ -9,7 +10,21 @@ class NetworkPrivateKeyMigration extends BaseMigration {
this.config.modules?.network?.implementation?.['libp2p-service']?.config?.privateKey;

if (networkPrivateKey) {
const directoryPath = join(this.config.appDataPath, LIBP2P_KEY_DIRECTORY);
let directoryPath;
if (process.env.NODE_ENV === 'testnet' || process.env.NODE_ENV === 'mainnet') {
directoryPath = join(
appRootPath.path,
'..',
this.config.appDataPath,
LIBP2P_KEY_DIRECTORY,
);
} else {
directoryPath = join(
appRootPath.path,
this.config.appDataPath,
LIBP2P_KEY_DIRECTORY,
);
}
const fullPath = join(directoryPath, LIBP2P_KEY_FILENAME);
await mkdir(directoryPath, { recursive: true });
await writeFile(fullPath, networkPrivateKey);
Expand Down

0 comments on commit 2f6317b

Please sign in to comment.