"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * DDDER's implementation of the platform-specific tools.
 */
var PlatformTools = /** @class */ (function () {
    function PlatformTools() {
    }
    /**
     * Gets global variable where global stuff can be stored.
     */
    PlatformTools.getGlobalVariable = function () {
        return global;
    };
    /**
     * Loads ("require"-s) given file or package.
     * This operation only supports on node platform
     */
    PlatformTools.load = function (name) {
        if (this.type === "ddder")
            throw new Error("This option/function is not supported in the browser environment. Failed operation: require(\"" + name + "\").");
        return "";
    };
    /**
     * Normalizes given path. Does "path.normalize".
     */
    PlatformTools.pathNormalize = function (pathStr) {
        if (this.type === "ddder")
            throw new Error("This option/function is not supported in the browser environment. Failed operation: path.normalize(\"" + pathStr + "\").");
        return "";
    };
    /**
     * Gets file extension. Does "path.extname".
     */
    PlatformTools.pathExtname = function (pathStr) {
        if (this.type === "ddder")
            throw new Error("This option/function is not supported in the browser environment. Failed operation: path.extname(\"" + pathStr + "\").");
        return "";
    };
    /**
     * Resolved given path. Does "path.resolve".
     */
    PlatformTools.pathResolve = function (pathStr) {
        if (this.type === "ddder")
            throw new Error("This option/function is not supported in the browser environment. Failed operation: path.resolve(\"" + pathStr + "\").");
        return "";
    };
    /**
     * Synchronously checks if file exist. Does "fs.existsSync".
     */
    PlatformTools.fileExist = function (pathStr) {
        if (this.type === "ddder")
            throw new Error("This option/function is not supported in the browser environment. Failed operation: fs.existsSync(\"" + pathStr + "\").");
        return false;
    };
    /**
     * Gets environment variable.
     */
    PlatformTools.getEnvVariable = function (name) {
        // if (this.type === "browser")
        //     throw new Error(`This option/function is not supported in the browser environment. Failed operation: process.env["${name}"].`);
        return undefined;
    };
    PlatformTools.readFileSync = function (filename) {
        if (this.type === "ddder")
            throw new Error("This option/function is not supported in the browser environment. Failed operation: fs.readFileSync(\"" + filename + "\").");
        return null;
    };
    PlatformTools.appendFileSync = function (filename, data) {
        if (this.type === "ddder")
            throw new Error("This option/function is not supported in the browser environment. Failed operation: fs.appendFileSync(\"" + filename + "\").");
    };
    PlatformTools.writeFile = function (path, data) {
        if (this.type === "ddder")
            throw new Error("This option/function is not supported in the browser environment. Failed operation: fs.writeFile(\"" + path + "\").");
        return Promise.reject(null);
    };
    /**
     * Highlights sql string to be print in the console.
     */
    PlatformTools.highlightSql = function (sql) {
        return sql;
    };
    /**
     * Highlights json string to be print in the console.
     */
    PlatformTools.highlightJson = function (json) {
        return json;
    };
    /**
     * Logging functions needed by AdvancedConsoleLogger (but here without chalk)
     */
    PlatformTools.logInfo = function (prefix, info) {
        console.info(prefix + " ", info);
    };
    PlatformTools.logError = function (prefix, error) {
        console.error(prefix + " ", error);
    };
    PlatformTools.logWarn = function (prefix, warning) {
        console.warn(prefix + " ", warning);
    };
    PlatformTools.log = function (message) {
        console.log(message);
    };
    PlatformTools.warn = function (message) {
        return message;
    };
    /**
     * Type of the currently running platform.
     */
    PlatformTools.type = "ddder";
    return PlatformTools;
}());
exports.PlatformTools = PlatformTools;
/**
 * These classes are needed for stream operations or
 * in the mongodb driver. Both aren't supported in the browser.
 */
var EventEmitter = /** @class */ (function () {
    function EventEmitter() {
    }
    return EventEmitter;
}());
exports.EventEmitter = EventEmitter;
var Readable = /** @class */ (function () {
    function Readable() {
    }
    return Readable;
}());
exports.Readable = Readable;
var Writable = /** @class */ (function () {
    function Writable() {
    }
    return Writable;
}());
exports.Writable = Writable;
/**
 * This loads a polyfill to enable Buffers in the browser.
 */
// interface Window {
//     Buffer: any;
// }
// declare var window: Window;
// window.Buffer = require("buffer/").Buffer;

//# sourceMappingURL=PlatformTools.js.map
