Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
Remove useless #! /usr/bin/env node
Browse files Browse the repository at this point in the history
  • Loading branch information
bokub committed Sep 19, 2018
1 parent d174907 commit 1158b13
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 12 deletions.
7 changes: 6 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node
'use strict';

const meow = require('meow');
const lyo = require('..');
const init = require('../lib/init');
Expand Down Expand Up @@ -38,7 +39,11 @@ const cli = meow(`

switch (cli.input[0]) {
case 'init':
init(cli.flags);
try {
init(cli.flags);
} catch (err) {
process.exit(1);
}
break;
case 'usage':
try {
Expand Down
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#! /usr/bin/env node
'use strict';

const task = require('./lib/task');
Expand Down
1 change: 0 additions & 1 deletion lib/display.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#! /usr/bin/env node
'use strict';

const chalk = require('chalk');
Expand Down
1 change: 0 additions & 1 deletion lib/get.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#! /usr/bin/env node
'use strict';

const path = require('path');
Expand Down
12 changes: 9 additions & 3 deletions lib/init.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#! /usr/bin/env node
'use strict';

const fs = require('fs');
Expand All @@ -7,14 +6,21 @@ const detectIndent = require('detect-indent');
const ora = require('ora');

function init(flags) {
const pkg = fs.readFileSync('package.json', 'utf8');
let pkg;
try {
pkg = fs.readFileSync('package.json', 'utf8');
} catch (err) {
ora().fail('Error reading package.json');
throw new Error(err);
}

const indent = detectIndent(pkg).indent || ' ';
const file = editJsonFile('package.json', {stringify_width: indent}); // eslint-disable-line camelcase
const done = {script: false, dependency: false, config: false};

if (Object.keys(file.get('')).length === 0) {
ora().fail('Error reading package.json');
process.exit(1);
throw new Error('Error reading package.json');
}

// Set prePublish script
Expand Down
1 change: 0 additions & 1 deletion lib/options.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#! /usr/bin/env node
'use strict';

const path = require('path').posix;
Expand Down
1 change: 0 additions & 1 deletion lib/pkg.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#! /usr/bin/env node
'use strict';

const path = require('path');
Expand Down
1 change: 0 additions & 1 deletion lib/save.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#! /usr/bin/env node
'use strict';

const fs = require('fs');
Expand Down
1 change: 0 additions & 1 deletion lib/task.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#! /usr/bin/env node
'use strict';

const chalk = require('chalk');
Expand Down
1 change: 0 additions & 1 deletion lib/usage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env node
'use strict';

const path = require('path');
Expand Down

3 comments on commit 1158b13

@marcus-sa
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you decide to remove #! /usr/bin/env node?
It's required on *Unix for it to work.

@bokub
Copy link
Owner Author

@bokub bokub commented on 1158b13 Sep 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only needed in cli.js, because that's the only file that is an executable script.

@marcus-sa
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my bad, thought you removed it from the executable script cli.js

Please sign in to comment.