@pkgr/utils
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -6,2 +6,13 @@ # Change Log | ||
## [0.1.1](https://github.com/rx-ts/pkgr/compare/@pkgr/utils@0.1.0...@pkgr/utils@0.1.1) (2019-10-28) | ||
### Bug Fixes | ||
* **webpack:** support vue app seamlessly :tada: ([42661b3](https://github.com/rx-ts/pkgr/commit/42661b395b37a5f035cccc1dff695ae888b7f241)) | ||
# 0.1.0 (2019-10-27) | ||
@@ -8,0 +19,0 @@ |
@@ -7,2 +7,4 @@ export declare const DEV: "development"; | ||
export declare const NODE_MODULES_REG: RegExp; | ||
export declare const CWD: string; | ||
export declare const EXTENSIONS: string[]; | ||
//# sourceMappingURL=constants.d.ts.map |
@@ -10,2 +10,6 @@ "use strict"; | ||
exports.NODE_MODULES_REG = /[\\/]node_modules[\\/]/; | ||
exports.CWD = process.cwd(); | ||
exports.EXTENSIONS = ['.ts', '.tsx'].concat( | ||
// eslint-disable-next-line node/no-deprecated-api | ||
Object.keys(require.extensions)); | ||
//# sourceMappingURL=constants.js.map |
export declare const tryPkg: (pkg: string) => string | undefined; | ||
export declare const isPkgAvailable: (pkg: string) => boolean; | ||
export declare const isTsAvailable: string | undefined; | ||
export declare const isReactAvailable: string | undefined; | ||
export declare const isMdxAvailable: string | undefined; | ||
export declare const isVueAvailable: string | undefined; | ||
export declare const isTsAvailable: boolean; | ||
export declare const isReactAvailable: boolean; | ||
export declare const isMdxAvailable: boolean; | ||
export declare const isVueAvailable: boolean; | ||
export declare const tryFile: (filePath?: string | string[] | undefined) => string; | ||
export declare const EXTENSIONS: string[]; | ||
export declare const tryExtensions: (filepath: string, extensions?: string[]) => string; | ||
@@ -10,0 +9,0 @@ export declare const identify: <T>(_: T) => _ is Exclude<T, "" | (T extends boolean ? false : boolean) | null | undefined>; |
@@ -8,2 +8,3 @@ "use strict"; | ||
var path_1 = __importDefault(require("path")); | ||
var constants_1 = require("./constants"); | ||
exports.tryPkg = function (pkg) { | ||
@@ -16,6 +17,6 @@ try { | ||
exports.isPkgAvailable = function (pkg) { return !!exports.tryPkg(pkg); }; | ||
exports.isTsAvailable = exports.tryPkg('typescript'); | ||
exports.isReactAvailable = exports.tryPkg('react'); | ||
exports.isMdxAvailable = exports.tryPkg('@mdx/mdx') || exports.tryPkg('@mdx/react'); | ||
exports.isVueAvailable = exports.tryPkg('vue'); | ||
exports.isTsAvailable = exports.isPkgAvailable('typescript'); | ||
exports.isReactAvailable = exports.isPkgAvailable('react'); | ||
exports.isMdxAvailable = exports.isPkgAvailable('@mdx/mdx') || exports.isPkgAvailable('@mdx/react'); | ||
exports.isVueAvailable = exports.isPkgAvailable('vue'); | ||
exports.tryFile = function (filePath) { | ||
@@ -33,14 +34,8 @@ if (typeof filePath === 'string') { | ||
}; | ||
// eslint-disable-next-line node/no-deprecated-api | ||
exports.EXTENSIONS = Object.keys(require.extensions); | ||
if (exports.isTsAvailable) { | ||
exports.EXTENSIONS.unshift('.ts', '.tsx'); | ||
} | ||
exports.tryExtensions = function (filepath, extensions) { | ||
if (extensions === void 0) { extensions = exports.EXTENSIONS; } | ||
var ext = extensions.find(function (ext) { return fs_1.default.existsSync(filepath + ext); }); | ||
if (extensions === void 0) { extensions = constants_1.EXTENSIONS; } | ||
var ext = extensions.concat('').find(function (ext) { return fs_1.default.existsSync(filepath + ext); }); | ||
return ext ? filepath + ext : ''; | ||
}; | ||
exports.identify = function (_) { return !!_; }; | ||
var cwd = process.cwd(); | ||
exports.findUp = function (searchEntry, searchFile) { | ||
@@ -50,3 +45,3 @@ if (searchFile === void 0) { searchFile = 'package.json'; } | ||
if (!exports.tryFile(searchEntry) || | ||
(searchEntry !== cwd && !searchEntry.startsWith(cwd + path_1.default.sep))) { | ||
(searchEntry !== constants_1.CWD && !searchEntry.startsWith(constants_1.CWD + path_1.default.sep))) { | ||
return ''; | ||
@@ -63,5 +58,5 @@ } | ||
searchEntry = path_1.default.resolve(searchEntry, '..'); | ||
} while (searchEntry === cwd || searchEntry.startsWith(cwd + path_1.default.sep)); | ||
} while (searchEntry === constants_1.CWD || searchEntry.startsWith(constants_1.CWD + path_1.default.sep)); | ||
return ''; | ||
}; | ||
//# sourceMappingURL=helpers.js.map |
{ | ||
"name": "@pkgr/utils", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Shared utils for `@pkgr` packages or any package else", | ||
@@ -23,3 +23,3 @@ "repository": "git+https://github.com/rx-ts/pkgr.git", | ||
"sideEffects": false, | ||
"gitHead": "be7c6a445d46f08039a86570092110c884fcc2b4" | ||
"gitHead": "cc0461d386de642cfdc174d7ffbe6cd5b8c678d0" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18739