From ac9deff1667c0d736d663c11fa114d035c459955 Mon Sep 17 00:00:00 2001 From: Esco Obong Date: Tue, 12 Sep 2017 02:10:43 -0400 Subject: [PATCH] use more idiomatic name for transpilation (lib->src), remove preset flag from package.json --- README.md | 14 +++++++------- package.json | 6 +++--- {lib => src}/index.js | 0 test/index.js | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) rename {lib => src}/index.js (100%) diff --git a/README.md b/README.md index 3b58df8..8bef6f4 100644 --- a/README.md +++ b/README.md @@ -84,10 +84,10 @@ getting something going, it's not a good idea to use it in production. We should be precompiling our files, so let's do that now. -First let's move our server `index.js` file to `lib/index.js`. +First let's move our server `index.js` file to `src/index.js`. ```shell -$ mv index.js lib/index.js +$ mv index.js src/index.js ``` And update our `npm start` script to reflect the location change. @@ -95,7 +95,7 @@ And update our `npm start` script to reflect the location change. ```diff "scripts": { - "start": "nodemon index.js --exec babel-node --presets es2015,stage-2" -+ "start": "nodemon lib/index.js --exec babel-node --presets es2015,stage-2" ++ "start": "nodemon src/index.js --exec babel-node --presets es2015,stage-2" } ``` @@ -103,7 +103,7 @@ Next let's add two new tasks, `npm run build` and `npm run serve`. ```diff "scripts": { - "start": "nodemon lib/index.js --exec babel-node --presets es2015,stage-2", + "start": "nodemon src/index.js --exec babel-node --presets es2015,stage-2", + "build": "babel lib -d dist --presets es2015,stage-2", + "serve": "node dist/index.js" } @@ -153,7 +153,7 @@ Now we can remove the duplicated options from our npm scripts ```diff "scripts": { -+ "start": "nodemon lib/index.js --exec babel-node", ++ "start": "nodemon src/index.js --exec babel-node", + "build": "babel lib -d dist", "serve": "node dist/index.js" } @@ -180,7 +180,7 @@ $ touch test/index.js import http from 'http'; import assert from 'assert'; -import '../lib/index.js'; +import '../src/index.js'; describe('Example Node Server', () => { it('should return 200', done => { @@ -202,7 +202,7 @@ Then we can add an `npm test` script. ```diff "scripts": { - "start": "nodemon lib/index.js --exec babel-node", + "start": "nodemon src/index.js --exec babel-node", "build": "babel lib -d dist", "serve": "node dist/index.js", + "test": "mocha --compilers js:babel-register" diff --git a/package.json b/package.json index dd6bdbb..1d04948 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,10 @@ "name": "example-node-server", "version": "1.0.0", "description": "Example Node Server w/ Babel", - "main": "lib/index.js", + "main": "src/index.js", "scripts": { - "start": "nodemon lib/index.js --exec babel-node --presets es2015,stage-2", - "build": "babel lib -d dist", + "start": "nodemon src/index.js --exec babel-node", + "build": "babel src -d dist", "serve": "node dist/index.js", "test": "mocha --compilers js:babel-register" }, diff --git a/lib/index.js b/src/index.js similarity index 100% rename from lib/index.js rename to src/index.js diff --git a/test/index.js b/test/index.js index 1f26cd7..ba7563a 100644 --- a/test/index.js +++ b/test/index.js @@ -1,7 +1,7 @@ import http from 'http'; import assert from 'assert'; -import '../lib/index.js'; +import '../src/index.js'; describe('Example Node Server', () => { it('should return 200', done => {