Skip to content

Commit ec8df99

Browse files
phatedactions-user
authored andcommitted
Build: Run prettier
1 parent 10d6916 commit ec8df99

File tree

4 files changed

+71
-70
lines changed

4 files changed

+71
-70
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ downloader.download('gulpjs', 'gulp', 'docs').then(console.log, console.error);
2121
```
2222

2323
You can also construct a downloader instance:
24+
2425
```js
2526
var { Downloader } = require('github-download-directory');
2627

@@ -30,8 +31,8 @@ var store = new KeyvFile();
3031

3132
var custom = new Downloader({
3233
cache: { store },
33-
github: { auth: 'SOME_AUTH_TOKEN' }
34-
})
34+
github: { auth: 'SOME_AUTH_TOKEN' },
35+
});
3536

3637
custom.download('gulpjs', 'gulp', 'docs').then(console.log, console.error);
3738
```

bin/github-download-directory.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/env node
22

3-
"use strict";
3+
'use strict';
44

5-
var minimist = require("minimist");
5+
var minimist = require('minimist');
66

7-
var gdd = require("../");
7+
var gdd = require('../');
88

99
var args = minimist(process.argv.slice(2));
1010

11-
var ownerAndRepo = args._[0] || "";
12-
var directory = args._[1] || "";
11+
var ownerAndRepo = args._[0] || '';
12+
var directory = args._[1] || '';
1313
var owner;
1414
var repo;
1515

@@ -33,8 +33,8 @@ if (!ownerAndRepo) {
3333
);
3434
}
3535

36-
if (ownerAndRepo.includes("/")) {
37-
var split = ownerAndRepo.split("/");
36+
if (ownerAndRepo.includes('/')) {
37+
var split = ownerAndRepo.split('/');
3838

3939
if (split.length > 2) {
4040
cliError(

index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
"use strict";
1+
'use strict';
22

3-
var fs = require("fs");
4-
var { dirname } = require("path");
5-
var { promisify } = require("util");
3+
var fs = require('fs');
4+
var { dirname } = require('path');
5+
var { promisify } = require('util');
66

7-
var Keyv = require("keyv");
8-
var { Octokit } = require("@octokit/rest");
7+
var Keyv = require('keyv');
8+
var { Octokit } = require('@octokit/rest');
99

1010
var mkdir = promisify(fs.mkdir);
1111
var writeFile = promisify(fs.writeFile);
@@ -14,7 +14,7 @@ var ONE_HOUR_IN_MS = 1000 * 3600;
1414

1515
var defaultCacheOpts = {
1616
ttl: ONE_HOUR_IN_MS,
17-
namespace: "github-download-directory",
17+
namespace: 'github-download-directory',
1818
};
1919

2020
async function createDirectories(filepath) {
@@ -37,7 +37,7 @@ class Downloader {
3737
}
3838

3939
async getTree(owner, repo, options = {}) {
40-
var sha = options.sha || "master";
40+
var sha = options.sha || 'master';
4141
var cacheKey = `${owner}/${repo}#${sha}`;
4242

4343
var cachedTree = await this.cache.get(cacheKey);
@@ -56,7 +56,7 @@ class Downloader {
5656

5757
await this.cache.set(cacheKey, tree);
5858

59-
if (typeof this.cache.save === "function") {
59+
if (typeof this.cache.save === 'function') {
6060
await this.cache.save();
6161
}
6262

@@ -67,7 +67,7 @@ class Downloader {
6767
var tree = await this.getTree(owner, repo, options);
6868

6969
var files = tree
70-
.filter((node) => node.path.startsWith(directory) && node.type === "blob")
70+
.filter((node) => node.path.startsWith(directory) && node.type === 'blob')
7171
.map(async (node) => {
7272
var { data } = await this._octokit.git.getBlob({
7373
owner,

test/index.js

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,101 @@
1-
"use strict";
1+
'use strict';
22

3-
var fs = require("fs");
4-
var expect = require("expect");
3+
var fs = require('fs');
4+
var expect = require('expect');
55

6-
var FileCache = require("keyv-file").KeyvFile;
6+
var FileCache = require('keyv-file').KeyvFile;
77

8-
var { Downloader } = require("../");
8+
var { Downloader } = require('../');
99

10-
describe("github-download-directory", function () {
10+
describe('github-download-directory', function () {
1111
function getPath(file) {
1212
return file.path;
1313
}
1414

1515
function onlyIndex(file) {
16-
return file.path === "index.js";
16+
return file.path === 'index.js';
1717
}
1818

19-
describe("fetchFiles", function () {
19+
describe('fetchFiles', function () {
2020
this.timeout(0);
2121

2222
// Not testing the singleton so we can auth
2323
const downloader = new Downloader({
2424
github: { auth: process.env.TEST_TOKEN },
2525
});
2626

27-
it("fetchs the files", async function () {
27+
it('fetchs the files', async function () {
2828
var files = await downloader.fetchFiles(
29-
"phated",
30-
"github-download-directory",
31-
""
29+
'phated',
30+
'github-download-directory',
31+
''
3232
);
3333
var paths = files.map(getPath);
3434
// Check a few paths
35-
expect(paths).toContain("index.js");
36-
expect(paths).toContain("LICENSE");
37-
expect(paths).toContain("README.md");
38-
expect(paths).toContain("package.json");
35+
expect(paths).toContain('index.js');
36+
expect(paths).toContain('LICENSE');
37+
expect(paths).toContain('README.md');
38+
expect(paths).toContain('package.json');
3939
});
4040

41-
it("filters the directory", async function () {
41+
it('filters the directory', async function () {
4242
var files = await downloader.fetchFiles(
43-
"phated",
44-
"github-download-directory",
45-
"bin"
43+
'phated',
44+
'github-download-directory',
45+
'bin'
4646
);
4747
var paths = files.map(getPath);
4848
// Just the bin file
49-
expect(paths).toEqual(["bin/github-download-directory.js"]);
49+
expect(paths).toEqual(['bin/github-download-directory.js']);
5050
});
5151

52-
it("uses the cache values if available", async function () {
53-
var key = "phated/github-download-directory#master";
52+
it('uses the cache values if available', async function () {
53+
var key = 'phated/github-download-directory#master';
5454
var cachedTree = await downloader.cache.get(key);
5555
await downloader.cache.set(key, cachedTree.filter(onlyIndex));
5656

5757
var files = await downloader.fetchFiles(
58-
"phated",
59-
"github-download-directory",
60-
""
58+
'phated',
59+
'github-download-directory',
60+
''
6161
);
6262
var paths = files.map(getPath);
6363
// Check it only contains index.js, which we set
64-
expect(paths).toEqual(["index.js"]);
64+
expect(paths).toEqual(['index.js']);
6565
});
6666

67-
it("reuses the cache between runs", async function () {
67+
it('reuses the cache between runs', async function () {
6868
var files = await downloader.fetchFiles(
69-
"phated",
70-
"github-download-directory",
71-
""
69+
'phated',
70+
'github-download-directory',
71+
''
7272
);
7373
var paths = files.map(getPath);
7474
// Check it only contains index.js, which we set
75-
expect(paths).toEqual(["index.js"]);
75+
expect(paths).toEqual(['index.js']);
7676
});
7777

78-
it("uses cache keys that include the SHA", async function () {
78+
it('uses cache keys that include the SHA', async function () {
7979
var files = await downloader.fetchFiles(
80-
"phated",
81-
"github-download-directory",
82-
"",
80+
'phated',
81+
'github-download-directory',
82+
'',
8383
{
84-
sha: "773c2f0f26fffeaecc1651102da1fd18098309c7",
84+
sha: '773c2f0f26fffeaecc1651102da1fd18098309c7',
8585
}
8686
);
8787
var paths = files.map(getPath);
8888
// Ensure we have a fresh set of files
89-
expect(paths).toContain("index.js");
90-
expect(paths).toContain("LICENSE");
91-
expect(paths).toContain("README.md");
92-
expect(paths).toContain("package.json");
89+
expect(paths).toContain('index.js');
90+
expect(paths).toContain('LICENSE');
91+
expect(paths).toContain('README.md');
92+
expect(paths).toContain('package.json');
9393
});
9494
});
9595

96-
describe("Downloader", function () {
97-
it("allows you to construct an new instance with custom cache", async function () {
98-
var filename = "test/.cache.json";
96+
describe('Downloader', function () {
97+
it('allows you to construct an new instance with custom cache', async function () {
98+
var filename = 'test/.cache.json';
9999

100100
var store = new FileCache({ filename });
101101

@@ -105,17 +105,17 @@ describe("github-download-directory", function () {
105105
});
106106

107107
var files = await downloader.fetchFiles(
108-
"phated",
109-
"github-download-directory",
110-
""
108+
'phated',
109+
'github-download-directory',
110+
''
111111
);
112112

113113
var paths = files.map(getPath);
114114
// Check a few paths
115-
expect(paths).toContain("index.js");
116-
expect(paths).toContain("LICENSE");
117-
expect(paths).toContain("README.md");
118-
expect(paths).toContain("package.json");
115+
expect(paths).toContain('index.js');
116+
expect(paths).toContain('LICENSE');
117+
expect(paths).toContain('README.md');
118+
expect(paths).toContain('package.json');
119119
// Make sure the file cache exists
120120
expect(fs.existsSync(filename)).toEqual(true);
121121
});

0 commit comments

Comments
 (0)