11#!/usr/bin/env node
22
3- var fs = require ( 'fs' ) ;
4- var path = require ( 'path' ) ;
3+ var fs = require ( 'fs' )
4+ var path = require ( 'path' )
55var argv = require ( 'nomnom' )
66 . script ( 'ldnode' )
77 . option ( 'verbose' , {
@@ -13,14 +13,14 @@ var argv = require('nomnom')
1313 flag : true ,
1414 help : 'Print current ldnode version' ,
1515 callback : function ( ) {
16- fs . readFile ( path . resolve ( __dirname , '../package.json' ) , 'utf-8' , function ( err , file ) {
17- console . log ( JSON . parse ( file ) . version ) ;
18- } ) ;
16+ fs . readFile ( path . resolve ( __dirname , '../package.json' ) , 'utf-8' , function ( _ , file ) {
17+ console . log ( JSON . parse ( file ) . version )
18+ } )
1919 }
2020 } )
2121 . option ( 'mount' , {
2222 abbr : 'm' ,
23- help : ' Relative URL from which to serve the Linked Data Platform (default: \'/\')'
23+ help : " Relative URL from which to serve the Linked Data Platform (default: '/')"
2424 } )
2525 . option ( 'root' , {
2626 abbr : 'r' ,
@@ -76,12 +76,12 @@ var argv = require('nomnom')
7676 } )
7777 . option ( 'suffixAcl' , {
7878 full : 'suffix-acl' ,
79- help : ' Suffix for acl files (default: \ '.acl\')' ,
79+ help : " Suffix for acl files (default: '.acl')" ,
8080 abbr : 'sA'
8181 } )
8282 . option ( 'suffixMeta' , {
8383 full : 'suffix-meta' ,
84- help : ' Suffix for metadata files (default: \ '.meta\')' ,
84+ help : " Suffix for metadata files (default: '.meta')" ,
8585 abbr : 'sM'
8686 } )
8787 . option ( 'noErrorPages' , {
@@ -97,42 +97,46 @@ var argv = require('nomnom')
9797 full : 'default-app' ,
9898 help : 'URI to use as a default app for resources (default: https://linkeddata.github.io/warp/#/list/)'
9999 } )
100- . parse ( ) ;
100+ . parse ( )
101101
102- // Print version and leave
103- if ( argv . version ) {
104- return ;
105- }
102+ function bin ( argv ) {
103+ // Print version and leave
104+ if ( argv . version ) {
105+ return 0
106+ }
106107
107- // Set up --no-*
108- argv . live = ! argv . noLive ;
108+ // Set up --no-*
109+ argv . live = ! argv . noLive
109110
110- // Set up debug environment
111- process . env . DEBUG = argv . verbose ? 'ldnode:*' : false ;
112- var debug = require ( '../lib/debug' ) . server ;
111+ // Set up debug environment
112+ process . env . DEBUG = argv . verbose ? 'ldnode:*' : false
113+ var debug = require ( '../lib/debug' ) . server
113114
114- // Set up port
115- argv . port = argv . port || 3456 ;
115+ // Set up port
116+ argv . port = argv . port || 3456
116117
117- // Signal handling (e.g. CTRL+C)
118- if ( process . platform !== 'win32' ) {
118+ // Signal handling (e.g. CTRL+C)
119+ if ( process . platform !== 'win32' ) {
119120 // Signal handlers don't work on Windows.
120- process . on ( 'SIGINT' , function ( ) {
121- debug ( " LDP stopped." ) ;
122- process . exit ( ) ;
123- } ) ;
124- }
121+ process . on ( 'SIGINT' , function ( ) {
122+ debug ( ' LDP stopped.' )
123+ process . exit ( )
124+ } )
125+ }
125126
126- // Finally starting ldnode
127- var ldnode = require ( '../' ) ;
128- var app ;
129- try {
130- app = ldnode . createServer ( argv ) ;
131- } catch ( e ) {
132- console . log ( e . message ) ;
133- console . log ( e . stack )
134- return 1 ;
127+ // Finally starting ldnode
128+ var ldnode = require ( '../' )
129+ var app
130+ try {
131+ app = ldnode . createServer ( argv )
132+ } catch ( e ) {
133+ console . log ( e . message )
134+ console . log ( e . stack )
135+ return 1
136+ }
137+ app . listen ( argv . port , function ( ) {
138+ debug ( 'LDP started on port ' + argv . port )
139+ } )
135140}
136- app . listen ( argv . port , function ( ) {
137- debug ( 'LDP started on port ' + argv . port ) ;
138- } ) ;
141+
142+ bin ( argv )
0 commit comments