Search results

Types

Classes
Interfaces
Enums
Functions
Type aliases
Constants

Members

Properties
Methods
Getters
Setters
Enum members
Show privates

Other

In this module only

Const FSFileHost

Defined in index.ts

File system file host. The default file host used by ts-docs.

Type

FileHostinterface FileHostts-docs/fileHost/FileHost

Content

{
    exists: (path) => fs.existsSync(path),
    createFile: (basePath, folder, file, content) => {
        const folderPath = path.join(basePath, folder);
        if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath);
        fs.writeFileSync(path.join(folderPath, file), content, "utf-8");
        return folderPath;
    },
    copyFolder: (origin, destination) => {
        for (const file of fs.readdirSync(origin, {withFileTypes: true})) {
            const newOrigin = path.join(origin, file.name);
            const newDestination = path.join(destination, file.name);
            if (file.isDirectory()) {
                if (!fs.existsSync(newDestination)) fs.mkdirSync(newDestination);
                FSFileHost.copyFolder(newOrigin, newDestination);
            }
            else fs.copyFileSync(newOrigin, newDestination);
        }
    },
    readFile: (path) => fs.readFileSync(path, "utf-8"),
    createDir: (p, name) => {
        const finalP = path.join(p, name);
        if (!fs.e...