vsc-material-but-i-wont-sue.../src/helpers/fs.ts
Alessio Occhipinti 50c057184c Feat/remove icons (#310)
* feat(Icons removal): Removed all related icons commands and files

* chore: fix (remove) all gulp related imports and task for icons

* chore: removed extensions folder and switch all imports (+ small fixes)

* chore: re-added defaults.json on root

* feat(Icons removal): Added vsc-material-theme-icons dependency
2019-01-31 21:35:51 +01:00

47 lines
1.2 KiB
TypeScript

import * as fs from 'fs';
import * as path from 'path';
import {IPackageJSON} from '../interfaces/ipackage.json';
import {CHARSET} from './../consts/files';
import {IDefaults} from '../interfaces/idefaults';
import {PATHS} from '../consts/paths';
export function ensureDir(dirname: string): void {
if (!fs.existsSync(dirname)) {
fs.mkdirSync(dirname);
}
}
export function getDefaultValues(): IDefaults {
const defaults: IDefaults = require(path.join(PATHS.VSIX_DIR, 'defaults.json'));
if (defaults === undefined || defaults === null) {
throw new Error('Cannot find defaults params');
}
return defaults;
}
export function getAbsolutePath(input: string): string {
return path.join(PATHS.VSIX_DIR, input);
}
export function getAccentsProperties() {
return getDefaultValues().accentsProperties;
}
/**
* Gets package JSON
*/
export function getPackageJSON(): IPackageJSON {
return require(path.join(PATHS.VSIX_DIR, './package.json'));
}
/**
* Writes a file inside the vsix directory
*/
export function writeFile(filename: string, filecontent: string): void {
const filePath = path.join(PATHS.VSIX_DIR, filename);
fs.writeFileSync(filePath, filecontent, {encoding: CHARSET});
}