forked from rauchg/slackin
-
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.
Switch to args, lint code and clean up (rauchg#200)
* Hide npm warnings * Use args instead of commander * Consitant naming * Ignore stuff * Put babel config into package.json * Lint code * Adjust code to get linted * npm does this by default * Proper task naming * Proper name for build output * Pin dependencies * Updated eslint-config-default
- Loading branch information
Showing
20 changed files
with
1,174 additions
and
1,166 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 |
---|---|---|
@@ -1,2 +1,8 @@ | ||
node | ||
# build output | ||
dist | ||
|
||
# dependencies | ||
node_modules | ||
|
||
# logs | ||
npm-debug.log |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,37 @@ | ||
#!/usr/bin/env node | ||
|
||
var pkg = require('./../package'); | ||
var program = require('commander'); | ||
var args = require('args'); | ||
var slackin = require('./../node').default; | ||
|
||
program | ||
.version(pkg.version) | ||
.usage('[options] <team-id> <api-token>') | ||
.option('-p, --port <port>', 'Port to listen on [$PORT or 3000]', require('hostenv').PORT || process.env.PORT || 3000) | ||
.option('-h, --hostname <hostname>', 'Hostname to listen on [$HOSTNAME or 0.0.0.0]', require('hostenv').HOSTNAME || process.env.WEBSITE_HOSTNAME || '0.0.0.0') | ||
.option('-c, --channels [<chan>]', 'One or more comma-separated channel names to allow single-channel guests [$SLACK_CHANNELS]', process.env.SLACK_CHANNELS) | ||
.option('-c, --channel <chan>', 'Single channel guest invite (deprecated) [$SLACK_CHANNEL]', process.env.SLACK_CHANNEL) | ||
.option('-i, --interval <int>', 'How frequently (ms) to poll Slack [$SLACK_INTERVAL or 5000]', process.env.SLACK_INTERVAL || 5000) | ||
.option('-P, --path <path>', 'Path to serve slackin under', '/') | ||
.option('-s, --silent', 'Do not print out warns or errors') | ||
.option('-C, --coc <coc>', 'Full URL to a CoC that needs to be agreed to') | ||
.option('-c, --css <file>', 'Full URL to a custom CSS file to use on the main page') | ||
.parse(process.argv); | ||
args | ||
.option(['p', 'port'], 'Port to listen on [$PORT or 3000]', require('hostenv').PORT || process.env.PORT || 3000) | ||
.option(['h', 'hostname'], 'Hostname to listen on [$HOSTNAME or 0.0.0.0]', require('hostenv').HOSTNAME || process.env.WEBSITE_HOSTNAME || '0.0.0.0') | ||
.option(['c', 'channels'], 'One or more comma-separated channel names to allow single-channel guests [$SLACK_CHANNELS]', process.env.SLACK_CHANNELS) | ||
.option(['i', 'interval'], 'How frequently (ms) to poll Slack [$SLACK_INTERVAL or 5000]', process.env.SLACK_INTERVAL || 5000) | ||
.option(['P', 'path'], 'Path to serve slackin under', '/') | ||
.option(['s', 'silent'], 'Do not print out warns or errors') | ||
.option(['C', 'coc'], 'Full URL to a CoC that needs to be agreed to') | ||
.option(['S', 'css'], 'Full URL to a custom CSS file to use on the main page'); | ||
|
||
var org = program.args[0] || process.env.SLACK_SUBDOMAIN; | ||
var token = program.args[1] || process.env.SLACK_API_TOKEN; | ||
var flags = args.parse(process.argv, { | ||
value: '<team-id> <api-token>' | ||
}); | ||
|
||
var org = args.sub[0] || process.env.SLACK_SUBDOMAIN; | ||
var token = args.sub[1] || process.env.SLACK_API_TOKEN; | ||
|
||
if (!org || !token) { | ||
program.help(); | ||
args.showHelp(); | ||
} else { | ||
program.org = org; | ||
program.token = token; | ||
flags.org = org; | ||
flags.token = token; | ||
} | ||
|
||
// support deprecated option | ||
if (!program.channels && program.channel) { | ||
program.channels = program.channel; | ||
} | ||
var port = flags.port; | ||
var hostname = flags.hostname; | ||
|
||
var port = program.port; | ||
var hostname = program.hostname; | ||
slackin(program).listen(port, hostname, function(err){ | ||
slackin(flags).listen(port, hostname, function(err){ | ||
if (err) throw err; | ||
if (!program.silent) console.log('%s – listening on %s:%d', new Date, hostname, port); | ||
if (!flags.silent) console.log('%s – listening on %s:%d', new Date, hostname, port); | ||
}); |
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 |
---|---|---|
@@ -1,30 +1,34 @@ | ||
'use strict'; | ||
|
||
import gulp from 'gulp'; | ||
import babel from 'gulp-babel'; | ||
import rimraf from 'gulp-rimraf'; | ||
import gulp from 'gulp' | ||
import babel from 'gulp-babel' | ||
import rimraf from 'gulp-rimraf' | ||
|
||
const paths = { | ||
in_js: "lib/*.js", | ||
in_assets: "lib/assets/*", | ||
out_js: "node", | ||
out_assets: "node/assets", | ||
}; | ||
in: { | ||
js: 'lib/*.js', | ||
assets: 'lib/assets/*' | ||
}, | ||
out: { | ||
js: 'dist', | ||
assets: 'dist/assets' | ||
} | ||
} | ||
|
||
gulp.task('es6to5', () => { | ||
return gulp.src(paths.in_js) | ||
.pipe(babel()) | ||
.pipe(gulp.dest(paths.out_js)); | ||
}); | ||
gulp.task('transpile', () => { | ||
return gulp.src(paths.in.js) | ||
.pipe(babel()) | ||
.pipe(gulp.dest(paths.out.js)) | ||
}) | ||
|
||
gulp.task('copyassets', () => { | ||
return gulp.src(paths.in_assets) | ||
.pipe(gulp.dest(paths.out_assets)); | ||
}); | ||
gulp.task('assets', () => { | ||
return gulp.src(paths.in.assets) | ||
.pipe(gulp.dest(paths.out.assets)) | ||
}) | ||
|
||
gulp.task('clean', () => { | ||
return gulp.src(paths.out_js, { read: false }) | ||
.pipe(rimraf()); | ||
}); | ||
return gulp.src(paths.out.js, { | ||
read: false | ||
}) | ||
.pipe(rimraf()) | ||
}) | ||
|
||
gulp.task('default', ['es6to5', 'copyassets']); | ||
gulp.task('default', ['transpile', 'assets']) |
Oops, something went wrong.