UNPKG

postcss-d-ts

Version:

PostCSS plugin to generate `.d.ts` of all used CSS classes and ids in imported stylesheets

33 lines (32 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.tempDir = exports.tempFileName = exports.$copy = exports.$rename = exports.$close = exports.$write = exports.$open = exports.$unlink = exports.$exists = exports.readlineSync = void 0; const schema = require("./schema.json"); const fs_1 = require("fs"); const os_1 = require("os"); const path_1 = require("path"); const util_1 = require("util"); const utils_1 = require("./utils"); const $exists = util_1.promisify(fs_1.exists), _unlink = util_1.promisify(fs_1.unlink), $open = util_1.promisify(fs_1.open), $write = util_1.promisify(fs_1.writeFile), $close = util_1.promisify(fs_1.close), $mkdir = util_1.promisify(fs_1.mkdir), $rename = util_1.promisify(fs_1.rename), $copy = util_1.promisify(fs_1.copyFile), tempDir = path_1.join(os_1.tmpdir(), schema.title); exports.$exists = $exists; exports.$open = $open; exports.$write = $write; exports.$close = $close; exports.$rename = $rename; exports.$copy = $copy; exports.tempDir = tempDir; function readlineSync(path, splitter) { return fs_1.readFileSync(path).toString() .split(splitter); } exports.readlineSync = readlineSync; function $unlink(source) { return $exists(source) .then(ex => ex ? _unlink(source) : void 0); } exports.$unlink = $unlink; async function tempFileName() { await $exists(tempDir) || await $mkdir(tempDir); return path_1.join(tempDir, utils_1.randomString()); } exports.tempFileName = tempFileName;