Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI modularized, express injection allowed #576

Merged
merged 2 commits into from Sep 5, 2017

Conversation

@tomasklapka
Copy link
Contributor

@tomasklapka tomasklapka commented Sep 5, 2017

As issued in #574
This is a simple modularization of CLI so it is possible to reuse it and inject own express like this:

#!/usr/bin/env node

const startCli = require('solid-server').startCli
const express = require('express')
const rdfFormatsProxy = require('http-rdf-formats-proxy')
const server = express()

server.get('/version', function (req, res) {
  res.json({ "version": require('./package.json').version })
})
server.use('/rdf-formats-proxy', rdfFormatsProxy())

startCli(server)

EDIT: renamed cli() to startCli()

@RubenVerborgh RubenVerborgh self-requested a review Sep 5, 2017
Copy link
Member

@RubenVerborgh RubenVerborgh left a comment

Approved with minor change suggestions.

bin/lib/cli.js Outdated

module.exports = function cli (server) {
program
.version(packageJson.version)
Copy link
Member

@RubenVerborgh RubenVerborgh Sep 5, 2017

(nitpick) Make this one line?

bin/lib/cli.js Outdated
var loadInit = require('./init')
var loadStart = require('./start')

module.exports = function cli (server) {
Copy link
Member

@RubenVerborgh RubenVerborgh Sep 5, 2017

Could the function name be more descriptive? Because it doesn't return anything. Maybe startCli or something like this?

bin/lib/cli.js Outdated
var program = require('commander')
var packageJson = require('../../package.json')
var loadInit = require('./init')
var loadStart = require('./start')
Copy link
Member

@RubenVerborgh RubenVerborgh Sep 5, 2017

Perhaps all of these can become const now.

@RubenVerborgh RubenVerborgh merged commit 310d95e into solid:release/v4.0.0 Sep 5, 2017
1 check passed
@RubenVerborgh
Copy link
Member

@RubenVerborgh RubenVerborgh commented Sep 5, 2017

Thanks!

@tomasklapka tomasklapka deleted the modularize-cli branch Sep 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants