Skip to content

Instantly share code, notes, and snippets.

@Graham42
Last active December 20, 2018 21:08
Show Gist options
  • Save Graham42/0f809cadc3460d021977e25d38bf082e to your computer and use it in GitHub Desktop.
Save Graham42/0f809cadc3460d021977e25d38bf082e to your computer and use it in GitHub Desktop.
Start a fresh nodejs project
#!/usr/bin/env bash
set -e;
npm init -y
node -e "const pkg = require('./package.json');
pkg.version = '0.0.0-dev'
pkg.license = 'MIT';
pkg.scripts = pkg.scripts || {};
pkg.scripts.lint = \"eslint . \";
pkg.scripts['//postshrinkwrap'] = \"echo 'See issue: https://npm.community/t/some-packages-have-dist-tarball-as-http-and-not-https/285/26'\"
pkg.scripts.postshrinkwrap = \"npx replace@1.0.0 'http://' 'https://' package-lock.json\"
require('fs').writeFileSync('package.json', JSON.stringify (pkg, null, 2), 'utf8');
"
npx @graham42/prettier-config
npm install -D eslint eslint-config-prettier
cat <<EOF > .eslintrc.js
module.exports = {
extends: ["eslint:recommended", "prettier"],
env: {
browser: true,
node: true,
es6: true,
},
rules: {
// logs are useful.
"no-console": "off",
},
};
EOF
cat <<EOF > .gitattributes
package-lock.json -diff
EOF
npx gitignore node
npm run format
git init
git add .
git commit -m "initial commit"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment