Skip to content

Commit

Permalink
Initial commit - project mockup
Browse files Browse the repository at this point in the history
  • Loading branch information
julianduque committed Apr 18, 2013
1 parent c5494c3 commit 6223a9d
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
*.log
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ $ npm install -g autostart
```
$ autostart --os sunos --command forever start /opt/apps/server.js
```
## Supported Platforms
* SunOS (pending)
* Linux (pending)
* Darwin (pending)
* Win32 (pending)

## License

Expand Down
36 changes: 36 additions & 0 deletions bin/autostart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env node

var autostart = require('../'),
optimist = require('optimist'),
prompt = require('prompt');

//
// Override params
//
prompt.override = optimist.argv;

//
// Welcome
//
console.log('Welcome to' + 'Autostart'.grey);
console.log('It worked if it ends with ' + 'Autostart '.grey + 'ok'.green);

//
// Start prompt
//
prompt.start();

prompt.get(['os', 'command'], function (err, params) {
var os = params.os,
command = params.command;

if (err) {
console.log(err);
return console.log('autostart: ' + 'not ok'.red);
}

console.log('Creating autostart script for ' + os.magenta);
autostart.create(os, command, function () {
console.log('Autostart '.grey + 'ok'.green);
});
});
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./lib/autostart');
26 changes: 26 additions & 0 deletions lib/autostart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var handlebars = require('handlebars'),
fs = require('fs');

var autostart = exports;

//
// _loadTemplate: Loads os template
//
function _loadTemplate(os, cb) {
cb(null);
}

autostart._loadTemplate = _loadTemplate;

autostart.create = function create(os, command, cb) {
//
// Load Template
//
_loadTemplate(os, function (err, template) {
if (err) {
return cb(err);
}

cb();
});
};
24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "autostart",
"version": "0.0.1",
"description": "Autostart a node process",
"main": "index.js",
"bin": "./bin/autostart",
"scripts": {
"test": "./node_modules/.bin/mocha --reporter spec"
},
"repository": "",
"author": "Julian Duque",
"license": "MIT",
"dependencies": {
"handlebars": "~1.0.10",
"optimist": "~0.4.0",
"prompt": "~0.2.9",
"mkdirp": "~0.3.5"
},
"readme": "README.md",
"devDependencies": {
"mocha": "~1.9.0",
"chai": "~1.5.0"
}
}
25 changes: 25 additions & 0 deletions test/darwin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var autostart = require('../'),
should = require('chai').should(),
assert = require('chai').assert,
fs = require('fs');

describe('Darwin Platform', function () {
describe('autostart', function () {

describe('#_loadTemplate', function () {
it('should exist', function () {
should.exist(autostart._loadTemplate);
});

it('should load a template');
});

describe('#create', function () {
it('should exist', function () {
should.exist(autostart.create);
});

it('should create an autostart install script');
});
});
});
25 changes: 25 additions & 0 deletions test/linux.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var autostart = require('../'),
should = require('chai').should(),
assert = require('chai').assert,
fs = require('fs');

describe('Linux Platform', function () {
describe('autostart', function () {

describe('#_loadTemplate', function () {
it('should exist', function () {
should.exist(autostart._loadTemplate);
});

it('should load a template');
});

describe('#create', function () {
it('should exist', function () {
should.exist(autostart.create);
});

it('should create an autostart install script');
});
});
});
25 changes: 25 additions & 0 deletions test/sunos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var autostart = require('../'),
should = require('chai').should(),
assert = require('chai').assert,
fs = require('fs');

describe('SunOS Platform', function () {
describe('autostart', function () {

describe('#_loadTemplate', function () {
it('should exist', function () {
should.exist(autostart._loadTemplate);
});

it('should load a template');
});

describe('#create', function () {
it('should exist', function () {
should.exist(autostart.create);
});

it('should create an autostart install script');
});
});
});
25 changes: 25 additions & 0 deletions test/win32.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var autostart = require('../'),
should = require('chai').should(),
assert = require('chai').assert,
fs = require('fs');

describe('Win32 Platform', function () {
describe('autostart', function () {

describe('#_loadTemplate', function () {
it('should exist', function () {
should.exist(autostart._loadTemplate);
});

it('should load a template');
});

describe('#create', function () {
it('should exist', function () {
should.exist(autostart.create);
});

it('should create an autostart install script');
});
});
});

0 comments on commit 6223a9d

Please sign in to comment.