forked from lighterio/lighter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
194 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env node | ||
var shellify = require('shellify'); | ||
|
||
shellify({ | ||
root: require.resolve('lighter').replace(/\/lighter\.js$/, '/'), | ||
commands: { | ||
dev: { | ||
note: 'Starts the app in development mode', | ||
options: { | ||
}, | ||
alias: 'd' | ||
}, | ||
prod: { | ||
note: 'Starts the app in production mode', | ||
options: { | ||
}, | ||
alias: 'p' | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function () { | ||
require('./start')('dev'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function () { | ||
require('./start')('prod'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
var shellify = require('shellify'); | ||
var spawn = require('child_process').spawn; | ||
|
||
module.exports = function (env) { | ||
|
||
/** | ||
* Start a Lighter app. | ||
*/ | ||
function start() { | ||
|
||
// Keep track of our start time. | ||
var started = new Date(); | ||
|
||
// Spawn a child process and make it output to stdout. | ||
var child = spawn(process.execPath, ['app'], {env: {NODE_ENV: env}}); | ||
child.stderr.pipe(process.stdout); | ||
child.stdout.pipe(process.stdout); | ||
|
||
// Restart once a second at most. | ||
child.on('close', function () { | ||
var elapsed = new Date() - started; | ||
delay = Math.max(1e3 - elapsed, 0); | ||
setTimeout(start, delay); | ||
}); | ||
} | ||
|
||
start(); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.