Skip to content

Instantly share code, notes, and snippets.

@richkevan
Last active March 29, 2024 16:22
Show Gist options
  • Save richkevan/7e4bd3f206e038990631724e5d9c7692 to your computer and use it in GitHub Desktop.
Save richkevan/7e4bd3f206e038990631724e5d9c7692 to your computer and use it in GitHub Desktop.
npm init configuration file that has been updated to create 1. Entry file 2. License 3. Code of Conduct 4. gitignore
const { exec } = require('child_process');
const fs = require('node:fs/promises');
module.exports = {
name: prompt('package name', basename || package.name),
version: prompt('version', '1.0.0'),
decription: prompt('description', ''),
main: prompt('entry point', 'index.js',async (filename) => {
console.log('Creating entry point file...', filename);
try {
await fs.writeFile(`./${filename}`, '')
} catch (err) {
console.error(err);
}
}),
keywords: prompt(function (s) { return s.split(/\s+/) }),
author: prompt('author', 'Rich Kevan <hey@richkevan.com> (https://richkevan.com)'),
license: prompt('license', 'MIT', (input) => {
try {} catch (err) {}
if (input != 'MIT') {
exec('npx license $(input)', (err) => {
if (err) {
console.error(`exec error: ${err}`);
return;
}
});
} else {
exec('npx license MIT', (err) => {
if (err) {
console.error(`exec error: ${err}`);
return;
}
});
}
}),
coc: prompt('code of conduct', "yes", (input) => {
if (input === "yes") {
exec('npx covgen hey@richkevan.com', (err) => {
if (err) {
console.error(`exec error: ${err}`);
return;
}
});
} else {
return;
}
}),
gitignore: prompt('gitignore', 'node', (input) => {
exec(`npx gitignore ${input}`, (err) => {
if (err) {
console.error(`exec error: ${err}`);
return;
}
});
}),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment