Comparing version 1.1.0 to 1.2.1
@@ -5,2 +5,26 @@ { | ||
{ | ||
"version": "1.2.1", | ||
"tag": "get-roots_v1.2.1", | ||
"date": "Tue, 03 Sep 2019 12:08:52 GMT", | ||
"comments": { | ||
"patch": [ | ||
{ | ||
"comment": "added readme" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"version": "1.2.0", | ||
"tag": "get-roots_v1.2.0", | ||
"date": "Tue, 03 Sep 2019 12:04:26 GMT", | ||
"comments": { | ||
"minor": [ | ||
{ | ||
"comment": "changed the signature from sync to async" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"version": "1.1.0", | ||
@@ -7,0 +31,0 @@ "tag": "get-roots_v1.1.0", |
# Change Log - get-roots | ||
This log was last generated on Wed, 28 Aug 2019 17:07:11 GMT and should not be manually modified. | ||
This log was last generated on Tue, 03 Sep 2019 12:08:52 GMT and should not be manually modified. | ||
## 1.2.1 | ||
Tue, 03 Sep 2019 12:08:52 GMT | ||
### Patches | ||
- added readme | ||
## 1.2.0 | ||
Tue, 03 Sep 2019 12:04:26 GMT | ||
### Minor changes | ||
- changed the signature from sync to async | ||
## 1.1.0 | ||
@@ -6,0 +20,0 @@ Wed, 28 Aug 2019 17:07:11 GMT |
29
index.js
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -14,15 +6,14 @@ const path_1 = require("path"); | ||
function getRootByFilename(location, filenames) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let newLocation = location; | ||
let currentLocation; | ||
do { | ||
currentLocation = newLocation; | ||
const exists = yield Promise.all(filenames.map(filename => fs_extra_1.pathExists(path_1.resolve(currentLocation, filename)))); | ||
if (yield exists.some(doExist => doExist === true)) { | ||
let newLocation = location; | ||
let currentLocation; | ||
do { | ||
currentLocation = newLocation; | ||
for (const filename of filenames) { | ||
if (fs_extra_1.pathExistsSync(path_1.resolve(currentLocation, filename))) { | ||
return currentLocation; | ||
} | ||
newLocation = path_1.dirname(currentLocation); | ||
} while (currentLocation !== newLocation); | ||
throw new Error('was not able to find root in ' + location); | ||
}); | ||
} | ||
newLocation = path_1.dirname(currentLocation); | ||
} while (currentLocation !== newLocation); | ||
throw new Error(`was not able to find root in ${location}`); | ||
} | ||
@@ -29,0 +20,0 @@ exports.getRootByFilename = getRootByFilename; |
13
index.ts
import {dirname, resolve} from "path"; | ||
import {pathExists} from "fs-extra"; | ||
import {pathExistsSync} from "fs-extra"; | ||
export async function getRootByFilename(location: string, filenames: string[]): Promise<string> { | ||
export function getRootByFilename(location: string, filenames: string[]): string { | ||
let newLocation = location; | ||
@@ -9,9 +9,10 @@ let currentLocation: string; | ||
currentLocation = newLocation; | ||
const exists = await Promise.all(filenames.map(filename => pathExists(resolve(currentLocation, filename)))); | ||
if (await exists.some(doExist => doExist === true)) { | ||
return currentLocation; | ||
for (const filename of filenames) { | ||
if (pathExistsSync(resolve(currentLocation, filename))) { | ||
return currentLocation; | ||
} | ||
} | ||
newLocation = dirname(currentLocation) | ||
} while (currentLocation !== newLocation); | ||
throw new Error('was not able to find root in ' + location) | ||
throw new Error(`was not able to find root in ${location}`) | ||
} | ||
@@ -18,0 +19,0 @@ |
{ | ||
"name": "get-roots", | ||
"version": "1.1.0", | ||
"version": "1.2.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
5009
7
109
1
26