Skip to content

Commit

Permalink
fix ping directory target (#2674)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuyHarwood authored Dec 11, 2023
1 parent 7660982 commit c89ca95
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions tslib/src/pupil-api/services/ping.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,9 @@ export class PingService {
return this.buildNumber
}

private distDir: string = ''

private getDistDirectoryPath (): string {
if (this.distDir !== '') return this.distDir
let currentDir = __dirname
const failSafe = 20
let count = 0
while (!fs.existsSync(path.join(currentDir, 'config.js'))) {
currentDir = path.join(currentDir, '..')
count++
if (count === failSafe) {
return './'
}
}
this.distDir = currentDir
return currentDir
}

private async loadCommitId (): Promise<any> {
const distDir = this.getDistDirectoryPath()
return new Promise(function (resolve) {
const commitFilePath = path.join(distDir, 'commit.txt')
const commitFilePath = path.join('./dist', 'commit.txt')
fs.readFile(commitFilePath, 'utf8', function (err, data) {
if (err == null) {
resolve(data)
Expand All @@ -52,9 +33,8 @@ export class PingService {
}

private async loadBuildNumber (): Promise<any> {
const distDir = this.getDistDirectoryPath()
return new Promise(function (resolve) {
const buildFilePath = path.join(distDir, 'build.txt')
const buildFilePath = path.join('./dist', 'build.txt')
fs.readFile(buildFilePath, 'utf8', function (err, data) {
if (err == null) {
resolve(data)
Expand Down

0 comments on commit c89ca95

Please sign in to comment.