-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathhook-helper.ts
38 lines (30 loc) · 868 Bytes
/
hook-helper.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"use strict";
import * as fs from "fs";
import * as path from "path";
export function findProjectDir(){
// start from the root of ns-unit-test-runner
let candidateDir = path.join(__dirname, "..");
while (true) {
let oldCandidateDir = candidateDir;
candidateDir = path.dirname(candidateDir);
if (path.basename(candidateDir) === 'node_modules') {
continue;
}
let packageJsonFile = path.join(candidateDir, 'package.json');
if (fs.existsSync(packageJsonFile)) {
return candidateDir;
}
if (oldCandidateDir === candidateDir) {
return;
}
}
}
export function getHooksDir() {
return path.join(findProjectDir(), 'hooks')
}
export function getAfterPrepareHookDir() {
return path.join(getHooksDir(), "after-prepare");
}
export function getHookFilePath() {
return path.join(getAfterPrepareHookDir(), "nativescript-unit-test-runner.js");
}