This repository has been archived by the owner on Jan 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
saysnoop.js
64 lines (55 loc) · 2.01 KB
/
saysnoop.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env node
(function (definition) {
'use strict';
// This file will function properly as a <script> tag, or a module
// using CommonJS and NodeJS or RequireJS module formats. In
// Common/Node/RequireJS, the module exports the saysnoop API and when
// executed as a simple <script>, it creates a saysnoop global instead.
var pkg = require('./package.json'),
saysnoop = require('./manager.js'),
taketalk = require('taketalk');
// Montage Require
if (typeof bootstrap === 'function') {
bootstrap('saysnoop', definition(pkg, saysnoop, taketalk));
// CommonJS
} else if (typeof exports === 'object' && typeof module === 'object') {
module.exports = definition(pkg, saysnoop, taketalk);
// RequireJS
} else if (typeof define === 'function' && define.amd) {
define(['pkg', 'saysnoop', 'taketalk'], definition);
// SES (Secure EcmaScript)
} else if (typeof ses !== 'undefined') {
if (!ses.ok()) {
return;
} else {
ses.makesaysnoop = definition(pkg, saysnoop, taketalk);
}
// <script>
} else if (typeof self !== 'undefined') {
self.saysnoop = definition(pkg, saysnoop, taketalk);
} else {
throw new Error('This environment was not anticipated by saysnoop. Please file a bug.');
}
})(function (pkg, saysnoop, taketalk) {
taketalk({
init: function (input, options) {
console.log(saysnoop(input, options));
},
help: function () {
console.log([
'',
' ' + pkg.description,
'',
' Usage',
' saysnoop <string>',
' saysnoop <string> --maxLength 8',
' echo <string> | saysnoop',
'',
' Example',
' saysnoop "Have you ever seen a rabbit with glasses?"',
saysnoop('Have you ever seen a rabbit with glasses?')
].join('\n'));
},
version: pkg.version
});
});