Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit ce85760

Browse files
authored
Avoid hard coded sample entry in management-api init script (#473)
1 parent 6624cc9 commit ce85760

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

source/management_api/initdb.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@ var path = require('path');
1818
var db;
1919
var cipher = require('./cipher');
2020

21+
var CONFIG_NAME = 'management_api.toml';
22+
var SAMPLE_RELATED_PATH = '../apps/current_app/';
23+
var DEFAULT_SAMPLE_ENTRY = 'samplertcservice.js';
24+
2125
var dirName = !process.pkg ? __dirname : path.dirname(process.execPath);
22-
var configFile = path.join(dirName, 'management_api.toml');
23-
var sampleServiceFile = path.resolve(dirName, '../apps/current_app/main.js');
26+
var configFile = path.resolve(dirName, CONFIG_NAME);
27+
var samplePackageJson = path.resolve(dirName, SAMPLE_RELATED_PATH, 'package.json');
28+
var sampleEntryName = (require(samplePackageJson).main || DEFAULT_SAMPLE_ENTRY);
29+
var sampleServiceFile = path.resolve(dirName, SAMPLE_RELATED_PATH, sampleEntryName);
2430

2531
function prepareDB(next) {
2632
if (fs.existsSync(cipher.astore)) {

0 commit comments

Comments
 (0)