mirror of
https://github.com/Raghu-Ch/nodeRestAPI.git
synced 2026-02-11 05:03:02 -05:00
initial commit
This commit is contained in:
12
node_modules/gulp-nodemon/.editorconfig
generated
vendored
Normal file
12
node_modules/gulp-nodemon/.editorconfig
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
12
node_modules/gulp-nodemon/.eslintrc.json
generated
vendored
Normal file
12
node_modules/gulp-nodemon/.eslintrc.json
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"env": { "es6": true, "node": true },
|
||||
"extends": "eslint:recommended",
|
||||
"rules": {
|
||||
"indent": ["error", 2],
|
||||
"linebreak-style": ["warn", "unix"],
|
||||
"quotes": ["error", "single"],
|
||||
"semi": ["error", "never"],
|
||||
"valid-jsdoc": ["error"],
|
||||
"no-console": "off"
|
||||
}
|
||||
}
|
||||
4
node_modules/gulp-nodemon/.npmignore
generated
vendored
Normal file
4
node_modules/gulp-nodemon/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
node_modules
|
||||
npm-debug.log
|
||||
.DS_Store
|
||||
.idea
|
||||
45
node_modules/gulp-nodemon/Gulpfile.js
generated
vendored
Normal file
45
node_modules/gulp-nodemon/Gulpfile.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
var gulp = require('gulp')
|
||||
, jshint = require('gulp-jshint')
|
||||
, nodemon = require('./index')
|
||||
// , path = require('path')
|
||||
|
||||
// gulp.task('test', function () {
|
||||
// gulp.src('./test/*-test.js')
|
||||
// .pipe(jshint({ asi: true, laxcomma: true }))
|
||||
// .pipe(mocha({ ui: 'bdd' }))
|
||||
// })
|
||||
|
||||
gulp.task('lint', function (){
|
||||
gulp.src('./*/**.js')
|
||||
.pipe(jshint())
|
||||
})
|
||||
|
||||
gulp.task('cssmin', function (){ /* void */
|
||||
})
|
||||
|
||||
gulp.task('afterstart', function (){
|
||||
console.log('proc has finished restarting!')
|
||||
})
|
||||
|
||||
gulp.task('test', ['lint'], function () {
|
||||
var stream = nodemon({
|
||||
nodemon: require('nodemon')
|
||||
, script: './test/server.js'
|
||||
, verbose: true
|
||||
, env: {
|
||||
'NODE_ENV': 'development'
|
||||
}
|
||||
, watch: './'
|
||||
, ext: 'js coffee'
|
||||
})
|
||||
|
||||
stream
|
||||
.on('restart', 'cssmin')
|
||||
.on('crash', function (){
|
||||
console.error('\nApplication has crashed!\n')
|
||||
console.error('Restarting in 2 seconds...\n')
|
||||
setTimeout(function () {
|
||||
stream.emit('restart')
|
||||
}, 2000)
|
||||
})
|
||||
})
|
||||
195
node_modules/gulp-nodemon/README.md
generated
vendored
Normal file
195
node_modules/gulp-nodemon/README.md
generated
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
gulp-nodemon
|
||||
===========
|
||||
|
||||
it's gulp + nodemon + convenience
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
$ npm install --save-dev gulp-nodemon
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Gulp-nodemon looks almost exactly like regular nodemon, but it's made for use with gulp tasks.
|
||||
|
||||
### **nodemon([options])**
|
||||
|
||||
You can pass an object to gulp-nodemon with options [like you would in nodemon config](https://github.com/remy/nodemon#config-files).
|
||||
|
||||
Example below will start `server.js` in `development` mode and watch for changes, as well as watch all `.html` and `.js` files in the directory.
|
||||
```js
|
||||
gulp.task('start', function () {
|
||||
nodemon({
|
||||
script: 'server.js'
|
||||
, ext: 'js html'
|
||||
, env: { 'NODE_ENV': 'development' }
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
## Synchronous Build Tasks
|
||||
|
||||
*NOTE: This feature requires Node v0.12 because of `child_process.spawnSync`.*
|
||||
|
||||
Nodemon is powerful but lacks the ability to compile/cleanup code prior to restarting the application... until now! Most build systems can never be complete without compilation, and now it works harmoniously with your nodemon loop.
|
||||
|
||||
### **{ tasks: [Array || Function(changedFiles)] }**
|
||||
|
||||
If you want to lint your code when you make changes that's easy to do with a simple event. But what if you need to wait while your project re-builds before you start it up again? This isn't possible with vanilla nodemon, and can be tedious to implement yourself, but it's easy with gulp-nodemon:
|
||||
```js
|
||||
nodemon({
|
||||
script: 'index.js'
|
||||
, tasks: ['browserify']
|
||||
})
|
||||
```
|
||||
|
||||
What if you want to decouple your build processes by language? Or even by file? Easy, just set the `tasks` option to a function. Gulp-nodemon will pass you the list of changed files and it'll let you return a list of tasks you want run.
|
||||
```js
|
||||
nodemon({
|
||||
script: './index.js'
|
||||
, ext: 'js css'
|
||||
, tasks: function (changedFiles) {
|
||||
var tasks = []
|
||||
changedFiles.forEach(function (file) {
|
||||
if (path.extname(file) === '.js' && !~tasks.indexOf('lint')) tasks.push('lint')
|
||||
if (path.extname(file) === '.css' && !~tasks.indexOf('cssmin')) tasks.push('cssmin')
|
||||
})
|
||||
return tasks
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## Events
|
||||
|
||||
gulp-nodemon returns a stream just like any other NodeJS stream, **except for the `on` method**, which conveniently accepts gulp task names in addition to the typical function.
|
||||
|
||||
### **.on([event], [Array || Function])**
|
||||
|
||||
1. `[event]` is an event name as a string. See [nodemon events](https://github.com/remy/nodemon/blob/master/doc/events.md).
|
||||
2. `[tasks]` An array of gulp task names or a function to execute.
|
||||
|
||||
### **.emit([event])**
|
||||
1. `event` is an event name as a string. See [nodemon events](https://github.com/remy/nodemon/blob/master/doc/events.md#using-nodemon-events).
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Usage
|
||||
|
||||
The following example will run your code with nodemon, lint it when you make changes, and log a message when nodemon runs it again.
|
||||
|
||||
```js
|
||||
// Gulpfile.js
|
||||
var gulp = require('gulp')
|
||||
, nodemon = require('gulp-nodemon')
|
||||
, jshint = require('gulp-jshint')
|
||||
|
||||
gulp.task('lint', function () {
|
||||
gulp.src('./**/*.js')
|
||||
.pipe(jshint())
|
||||
})
|
||||
|
||||
gulp.task('develop', function () {
|
||||
var stream = nodemon({ script: 'server.js'
|
||||
, ext: 'html js'
|
||||
, ignore: ['ignored.js']
|
||||
, tasks: ['lint'] })
|
||||
|
||||
stream
|
||||
.on('restart', function () {
|
||||
console.log('restarted!')
|
||||
})
|
||||
.on('crash', function() {
|
||||
console.error('Application has crashed!\n')
|
||||
stream.emit('restart', 10) // restart the server in 10 seconds
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
_**You can also plug an external version or fork of nodemon**_
|
||||
```js
|
||||
gulp.task('pluggable', function() {
|
||||
nodemon({ nodemon: require('nodemon'),
|
||||
script: 'server.js'})
|
||||
})
|
||||
```
|
||||
|
||||
### Bunyan Logger integration
|
||||
|
||||
The [bunyan](https://github.com/trentm/node-bunyan/) logger includes a `bunyan` script that beautifies JSON logging when piped to it. Here's how you can you can pipe your output to `bunyan` when using `gulp-nodemon`:
|
||||
|
||||
```js
|
||||
gulp.task('run', ['default', 'watch'], function() {
|
||||
var nodemon = require('gulp-nodemon'),
|
||||
spawn = require('child_process').spawn,
|
||||
bunyan
|
||||
|
||||
nodemon({
|
||||
script: paths.server,
|
||||
ext: 'js json',
|
||||
ignore: [
|
||||
'var/',
|
||||
'node_modules/'
|
||||
],
|
||||
watch: [paths.etc, paths.src],
|
||||
stdout: false,
|
||||
readable: false
|
||||
})
|
||||
.on('readable', function() {
|
||||
|
||||
// free memory
|
||||
bunyan && bunyan.kill()
|
||||
|
||||
bunyan = spawn('./node_modules/bunyan/bin/bunyan', [
|
||||
'--output', 'short',
|
||||
'--color'
|
||||
])
|
||||
|
||||
bunyan.stdout.pipe(process.stdout)
|
||||
bunyan.stderr.pipe(process.stderr)
|
||||
|
||||
this.stdout.pipe(bunyan.stdin)
|
||||
this.stderr.pipe(bunyan.stdin)
|
||||
});
|
||||
})
|
||||
```
|
||||
|
||||
## Using `gulp-nodemon` with React, Browserify, Babel, ES2015, etc.
|
||||
|
||||
Gulp-nodemon is made to work with the "groovy" new tools like Babel, JSX, and other JavaScript compilers/bundlers/transpilers.
|
||||
|
||||
In gulp-nodemon land, you'll want one task for compilation that uses an on-disk cache (e.g. `gulp-file-cache`, `gulp-cache-money`) along with your bundler (e.g. `gulp-babel`, `gulp-react`, etc.). Then you'll put `nodemon({})` in another task and pass the entire compile task in your config:
|
||||
|
||||
```js
|
||||
var gulp = require('gulp')
|
||||
, nodemon = require('gulp-nodemon')
|
||||
, babel = require('gulp-babel')
|
||||
, Cache = require('gulp-file-cache')
|
||||
|
||||
var cache = new Cache();
|
||||
|
||||
gulp.task('compile', function () {
|
||||
var stream = gulp.src('./src/**/*.js') // your ES2015 code
|
||||
.pipe(cache.filter()) // remember files
|
||||
.pipe(babel({ ... })) // compile new ones
|
||||
.pipe(cache.cache()) // cache them
|
||||
.pipe(gulp.dest('./dist')) // write them
|
||||
return stream // important for gulp-nodemon to wait for completion
|
||||
})
|
||||
|
||||
gulp.task('watch', ['compile'], function () {
|
||||
var stream = nodemon({
|
||||
script: 'dist/' // run ES5 code
|
||||
, watch: 'src' // watch ES2015 code
|
||||
, tasks: ['compile'] // compile synchronously onChange
|
||||
})
|
||||
|
||||
return stream
|
||||
})
|
||||
```
|
||||
|
||||
The cache keeps your development flow moving quickly and the `return stream` line ensure that your tasks get run in order. If you want them to run async, just remove that line.
|
||||
|
||||
## Using `gulp-nodemon` with `browser-sync`
|
||||
|
||||
Some people want to use `browser-sync`. That's totally fine, just start browser sync in the same task as `nodemon({})` and use gulp-nodemon's `.on('start', function () {})` to trigger browser-sync. Don't use the `.on('restart')` event because it will fire before your app is up and running.
|
||||
98
node_modules/gulp-nodemon/index.js
generated
vendored
Normal file
98
node_modules/gulp-nodemon/index.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
'use strict'
|
||||
|
||||
var nodemon
|
||||
, colors = require('colors')
|
||||
, gulp = require('gulp')
|
||||
, cp = require('child_process')
|
||||
, bus = require('nodemon/lib/utils/bus')
|
||||
|
||||
module.exports = function (options) {
|
||||
options = options || {};
|
||||
|
||||
// plug nodemon
|
||||
if (options.nodemon && typeof options.nodemon === 'function') {
|
||||
nodemon = options.nodemon
|
||||
delete options.nodemon
|
||||
} else {
|
||||
nodemon = require('nodemon')
|
||||
}
|
||||
|
||||
// Our script
|
||||
var script = nodemon(options)
|
||||
, originalOn = script.on
|
||||
, originalListeners = bus.listeners('restart')
|
||||
|
||||
// Allow for injection of tasks on file change
|
||||
if (options.tasks) {
|
||||
// Remove all 'restart' listeners
|
||||
bus.removeAllListeners('restart')
|
||||
|
||||
// Place our listener in first position
|
||||
bus.on('restart', function (files){
|
||||
if (!options.quiet) nodemonLog('running tasks...')
|
||||
|
||||
if (typeof options.tasks === 'function') run(options.tasks(files))
|
||||
else run(options.tasks)
|
||||
})
|
||||
|
||||
// Re-add all other listeners
|
||||
for (var i = 0; i < originalListeners.length; i++) {
|
||||
bus.on('restart', originalListeners[i])
|
||||
}
|
||||
}
|
||||
|
||||
// Capture ^C
|
||||
var exitHandler = function (options){
|
||||
if (options.exit) script.emit('exit')
|
||||
if (options.quit) process.exit(0)
|
||||
}
|
||||
process.once('exit', exitHandler.bind(null, { exit: true }))
|
||||
process.once('SIGINT', exitHandler.bind(null, { quit: true }))
|
||||
|
||||
// Forward log messages and stdin
|
||||
script.on('log', function (log){
|
||||
nodemonLog(log.message)
|
||||
})
|
||||
|
||||
// Shim 'on' for use with gulp tasks
|
||||
script.on = function (event, tasks){
|
||||
var tasks = Array.prototype.slice.call(arguments)
|
||||
, event = tasks.shift()
|
||||
|
||||
if (event === 'change') {
|
||||
script.changeTasks = tasks
|
||||
} else {
|
||||
for (var i = 0; i < tasks.length; i++) {
|
||||
void function (tasks){
|
||||
if (tasks instanceof Function) {
|
||||
originalOn(event, tasks)
|
||||
} else {
|
||||
originalOn(event, function (){
|
||||
if (Array.isArray(tasks)) {
|
||||
tasks.forEach(function (task){
|
||||
run(task)
|
||||
})
|
||||
} else run(tasks)
|
||||
})
|
||||
}
|
||||
}(tasks[i])
|
||||
}
|
||||
}
|
||||
|
||||
return script
|
||||
}
|
||||
|
||||
return script
|
||||
|
||||
// Synchronous alternative to gulp.run()
|
||||
function run(tasks) {
|
||||
if (typeof tasks === 'string') tasks = [tasks]
|
||||
if (tasks.length === 0) return
|
||||
if (!(tasks instanceof Array)) throw new Error('Expected task name or array but found: ' + tasks)
|
||||
cp.spawnSync(process.platform === 'win32' ? 'gulp.cmd' : 'gulp', tasks, { stdio: [0, 1, 2] })
|
||||
}
|
||||
}
|
||||
|
||||
function nodemonLog(message){
|
||||
console.log('[' + new Date().toString().split(' ')[4].gray + '] ' + ('[nodemon] ' + message).yellow)
|
||||
}
|
||||
108
node_modules/gulp-nodemon/package.json
generated
vendored
Normal file
108
node_modules/gulp-nodemon/package.json
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "gulp-nodemon",
|
||||
"scope": null,
|
||||
"escapedName": "gulp-nodemon",
|
||||
"name": "gulp-nodemon",
|
||||
"rawSpec": "",
|
||||
"spec": "latest",
|
||||
"type": "tag"
|
||||
},
|
||||
"C:\\Users\\chvra\\Documents\\angular-play\\nodeRest"
|
||||
]
|
||||
],
|
||||
"_from": "gulp-nodemon@latest",
|
||||
"_id": "gulp-nodemon@2.2.1",
|
||||
"_inCache": true,
|
||||
"_location": "/gulp-nodemon",
|
||||
"_nodeVersion": "6.3.1",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-12-west.internal.npmjs.com",
|
||||
"tmp": "tmp/gulp-nodemon-2.2.1.tgz_1475128514312_0.4443575507029891"
|
||||
},
|
||||
"_npmUser": {
|
||||
"name": "jacksongariety",
|
||||
"email": "jackson@gariety.xxx"
|
||||
},
|
||||
"_npmVersion": "3.10.5",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "gulp-nodemon",
|
||||
"scope": null,
|
||||
"escapedName": "gulp-nodemon",
|
||||
"name": "gulp-nodemon",
|
||||
"rawSpec": "",
|
||||
"spec": "latest",
|
||||
"type": "tag"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/gulp-nodemon/-/gulp-nodemon-2.2.1.tgz",
|
||||
"_shasum": "d9bf199f5585458159d3d299153e60b46868b6f4",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "gulp-nodemon",
|
||||
"_where": "C:\\Users\\chvra\\Documents\\angular-play\\nodeRest",
|
||||
"author": {
|
||||
"name": "Jackson Gariety"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/JacksonGariety/gulp-nodemon/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"colors": "^1.0.3",
|
||||
"event-stream": "^3.2.1",
|
||||
"gulp": "^3.9.1",
|
||||
"nodemon": "^1.10.2"
|
||||
},
|
||||
"description": "it's gulp + nodemon + convenience",
|
||||
"devDependencies": {
|
||||
"coffee-script": "^1.7.1",
|
||||
"gulp-jshint": "^1.6.1",
|
||||
"gulp-mocha": "^0.2.0",
|
||||
"is-running": "^1.0.3",
|
||||
"should": "^4.0.0"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"dist": {
|
||||
"shasum": "d9bf199f5585458159d3d299153e60b46868b6f4",
|
||||
"tarball": "https://registry.npmjs.org/gulp-nodemon/-/gulp-nodemon-2.2.1.tgz"
|
||||
},
|
||||
"gitHead": "485614c1bf7cf1c8192c570423bd2e5b24e5f81c",
|
||||
"homepage": "https://github.com/JacksonGariety/gulp-nodemon",
|
||||
"keywords": [
|
||||
"gulp",
|
||||
"nodemon",
|
||||
"develop",
|
||||
"server",
|
||||
"restart",
|
||||
"automatically",
|
||||
"watch",
|
||||
"gulpfriendly",
|
||||
"gulpplugin"
|
||||
],
|
||||
"license": "BSD-2-Clause",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "jacksongariety",
|
||||
"email": "personal@jacksongariety.com"
|
||||
}
|
||||
],
|
||||
"name": "gulp-nodemon",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/JacksonGariety/gulp-nodemon.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "gulp test"
|
||||
},
|
||||
"version": "2.2.1"
|
||||
}
|
||||
13
node_modules/gulp-nodemon/test/server.js
generated
vendored
Normal file
13
node_modules/gulp-nodemon/test/server.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
const http = require('http')
|
||||
|
||||
const port = 8000
|
||||
const hostname = '0.0.0.0'
|
||||
|
||||
http.createServer((req, res) => res.end(`
|
||||
Hello World, from the future!
|
||||
It's ${
|
||||
new Date().getFullYear() + Math.ceil(Math.random() * 100)
|
||||
} here, how is it going back there in ${new Date().getFullYear()}? :)
|
||||
|
||||
`))
|
||||
.listen(port, hostname, () => console.info(`listening on http://${hostname}:${port}`))
|
||||
Reference in New Issue
Block a user