create-7geese-component
Version:
💎 A CLI for creating new 7Geese components
20 lines (17 loc) • 616 B
JavaScript
import path from 'path';
import { writeFile } from 'fs';
const getWritePath = (configPath, writePath) => path.resolve(
process.cwd(),
configPath,
writePath
);
export default config => (filePath, fileContents) => new Promise((res, rej) => {
const writePath = getWritePath(config.path, filePath);
return writeFile(writePath, fileContents, 'utf8', err => {
if (err) {
console.warn(`Failed to write ${filePath} to file!`); // eslint-disable-line no-console
rej(`Failed to write ${filePath} to file!`);
}
res(`Wrote ${filePath} to file`);
});
});