Files
DefinitelyTyped/types/parent-package-json/parent-package-json-tests.ts
Simon McClive 254fb86815 Add types for parent-package-json (#20714)
* Add types for parent-package-json

* Update return type to false and restructure tests

* Remove multiple calls of parent() in tests

* Test optional properties
2017-10-19 11:38:48 -07:00

11 lines
323 B
TypeScript

import * as parent from 'parent-package-json';
const hasParent = parent('/optional/path/', 1);
if (hasParent !== false) {
const pathToParent: string = hasParent.path;
const contentOfParent: string = hasParent.read();
const JSONOfParent = hasParent.parse();
const versionOfParent = JSONOfParent.version;
}