-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.js
38 lines (32 loc) · 1.19 KB
/
install.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
var config = [
'development:',
' url: "http://1.lvh.me"',
' key: key',
' secret: secret',
' connectPath: "/twitter_connect"',
' callbackPath: "/twitter_callback"',
'production:',
' url: "http://example.com"',
' key: key',
' secret: secret',
' connectPath: "/twitter_connect"',
' callbackPath: "/twitter_callback"\n'
].join('\n');
var observer = [
'app.on(\'twitterConnect\', function (user, req, res) {',
' var location = req.session && req.session.beforeTwitterAuth || \'/\';',
' delete req.session.beforeTwitterAuth;',
' res.redirect(location);',
'});\n'
].join('\n');
var fs = require('fs');
var path = require('path');
if (path.existsSync(app.root + '/config') && !path.existsSync(app.root + '/config/twitter.yml')) {
fs.writeFileSync(app.root + '/config/twitter.yml', config);
console.log('new file ./config/twitter.yml');
}
if (path.existsSync(app.root + '/app/observers') && !path.existsSync(app.root + '/app/observers/twitter_observer.js')) {
fs.writeFileSync(app.root + '/app/observers/twitter_observer.js', observer);
console.log('new file ./app/observers/twitter_observer.js');
}
process.exit(0);