eyeglass
Version:
Sass modules for npm.
42 lines • 1.83 kB
JavaScript
;
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const semver = __importStar(require("semver"));
const DEFAULT_VERSION = "0.0.0";
class Deprecator {
constructor(options) {
this.ignoreDeprecations = options && options.eyeglass && options.eyeglass.ignoreDeprecations;
}
isEnabled(sinceVersion) {
// if `enabled` is undefined, try to set it
if (this.enabled === undefined) {
// if `disableDeprecations`, we fallback to the env variable
if (this.ignoreDeprecations === undefined) {
// return early and don't set `enabled`, as we'll check the env every time
// TODO: Ask eugene why we need to worry about the env variable changing.
return !semver.lte(sinceVersion, process.env.EYEGLASS_DEPRECATIONS || DEFAULT_VERSION);
}
this.enabled = !semver.lte(sinceVersion, this.ignoreDeprecations || DEFAULT_VERSION);
}
return this.enabled;
}
deprecate(sinceVersion, removeVersion, message) {
if (this.isEnabled(sinceVersion)) {
// eslint-disable-next-line no-console
console.warn("[eyeglass:deprecation]", "(deprecated in " + sinceVersion + ", will be removed in " + removeVersion + ")", message);
}
}
}
exports.Deprecator = Deprecator;
const factory = (options) => {
let deprecator = new Deprecator(options);
return deprecator.deprecate.bind(deprecator);
};
exports.default = factory;
//# sourceMappingURL=deprecator.js.map