UNPKG

howsmydriving-utils

Version:

Utilities used by howsmydriving package any howsmydriving-[region] plug-in modules.

25 lines (24 loc) 872 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var path = require("path"); var fs = require("fs"); // Fake a sleep function. Call this thusly: // sleep(500).then(() => { // do stuff // }) // Or similar pattrs that use a Promise function sleep(milliseconds) { return new Promise(function (resolve) { return setTimeout(resolve, milliseconds); }); } exports.sleep = sleep; function getAppRootPath() { var root_path = path.resolve(__dirname + '/../../'); if (!fs.existsSync(path.resolve(root_path, 'package.json'))) { root_path = path.resolve(__dirname + '/../../../'); if (!fs.existsSync(path.resolve(root_path, 'package.json'))) { throw new Error("Cannot find app root path containing package.json: " + __dirname + "."); } } return root_path; } exports.getAppRootPath = getAppRootPath;