Skip to content

Commit aa51f55

Browse files
authored
Merge pull request #13 from aj-may/aj-may/linux-support
feat: basic linux support
2 parents 6f966c1 + 43ee149 commit aa51f55

4 files changed

Lines changed: 36 additions & 2 deletions

File tree

.releaserc.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
[
77
"@semantic-release/github",
88
{
9-
"assets": [{ "path": "dist/dotdocker", "label": "dotdocker" }]
9+
"assets": [
10+
{ "path": "dist/dotdocker-macos", "label": "dotdocker-macos" },
11+
{ "path": "dist/dotdocker-linux", "label": "dotdocker-linux" }
12+
]
1013
}
1114
]
1215
]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"format": "prettier --write \"**/*.{json,css,scss,md,html}\"",
3232
"lint": "eslint .",
3333
"lint:md": "markdownlint -i node_modules -i build .",
34-
"build": "babel src -d build --copy-files && pkg --targets=node12-macos --out-path=dist .",
34+
"build": "babel src -d build --copy-files && pkg --targets=node12-macos,node12-linux --out-path=dist .",
3535
"semantic-release": "semantic-release"
3636
},
3737
"bin": {

src/tasks/setupDNS/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import { capitalize } from 'lodash';
22
import darwinDnsSetup from './darwin';
3+
import linuxDnsSetup from './linux';
34

45
const setupDNS = () => {
56
switch (process.platform) {
67
case 'darwin':
78
return darwinDnsSetup;
89

10+
case 'linux':
11+
return linuxDnsSetup;
12+
913
default:
1014
return {
1115
title: `Setting up DNS`,

src/tasks/setupDNS/linux.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { readFile as readFileCallback, writeFile as writeFileCallback } from 'fs';
2+
import { promisify } from 'util';
3+
4+
const readFile = promisify(readFileCallback);
5+
const writeFile = promisify(writeFileCallback);
6+
const resolverPath = '/etc/resolv.conf';
7+
const resolverLine = 'nameserver 127.0.0.1 # Generated by dotdocker';
8+
9+
export default {
10+
title: 'Setting up DNS',
11+
task: async () => {
12+
try {
13+
const resolverContents = await readFile(resolverPath);
14+
await writeFile(resolverPath, `${resolverLine}\n\n${resolverContents}`);
15+
} catch (err) {
16+
if (err.code === 'EACCES')
17+
throw new Error(
18+
'This task needs elevated permissions. Please run again using sudo. This only needs to be done once.',
19+
);
20+
throw err;
21+
}
22+
},
23+
skip: async () => {
24+
const resolverContents = await readFile(resolverPath);
25+
return resolverContents.includes(resolverLine);
26+
},
27+
};

0 commit comments

Comments
 (0)