bit-bin
Version:
<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b
22 lines (19 loc) • 656 B
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isRelativeImport;
// @flow
/**
* returns whether a the require/import path is relative.
*
* the criteria is taken from http://www.typescriptlang.org/docs/handbook/module-resolution.html
* Quote: A relative import is one that starts with /, ./ or ../. Some examples include:
* import Entry from "./components/Entry";
* import { DefaultHeaders } from "../constants/http";
* import "/mod";
* End quote.
*/
function isRelativeImport(str) {
return str.startsWith('./') || str.startsWith('../') || str.startsWith('/') || str === '.' || str === '..';
}