@cparra/apexdocs 3.0.0-alpha.7 → 3.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/generate.js
CHANGED
|
@@ -1525,7 +1525,7 @@ var __spreadValues$7 = (a, b) => {
|
|
|
1525
1525
|
return a;
|
|
1526
1526
|
};
|
|
1527
1527
|
var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
|
|
1528
|
-
var __async$
|
|
1528
|
+
var __async$4 = (__this, __arguments, generator) => {
|
|
1529
1529
|
return new Promise((resolve, reject) => {
|
|
1530
1530
|
var fulfilled = (value) => {
|
|
1531
1531
|
try {
|
|
@@ -1577,7 +1577,7 @@ function generateDocs(apexBundles, config) {
|
|
|
1577
1577
|
}
|
|
1578
1578
|
function transformReferenceHook(config) {
|
|
1579
1579
|
function _execute(references, parsedFiles, transformReference) {
|
|
1580
|
-
return __async$
|
|
1580
|
+
return __async$4(this, null, function* () {
|
|
1581
1581
|
return {
|
|
1582
1582
|
references: yield execTransformReferenceHook(Object.values(references), transformReference),
|
|
1583
1583
|
parsedFiles
|
|
@@ -1598,8 +1598,8 @@ function transformDocumentationBundleHook(config) {
|
|
|
1598
1598
|
function passThroughHook(value) {
|
|
1599
1599
|
return value;
|
|
1600
1600
|
}
|
|
1601
|
-
const execTransformReferenceHook = (_0, ..._1) => __async$
|
|
1602
|
-
const hooked = references.map((reference) => __async$
|
|
1601
|
+
const execTransformReferenceHook = (_0, ..._1) => __async$4(void 0, [_0, ..._1], function* (references, hook = passThroughHook) {
|
|
1602
|
+
const hooked = references.map((reference) => __async$4(void 0, null, function* () {
|
|
1603
1603
|
const hookedResult = yield hook(reference);
|
|
1604
1604
|
return __spreadValues$7(__spreadValues$7({}, reference), hookedResult);
|
|
1605
1605
|
}));
|
|
@@ -1609,24 +1609,24 @@ const execTransformReferenceHook = (_0, ..._1) => __async$2(void 0, [_0, ..._1],
|
|
|
1609
1609
|
return acc;
|
|
1610
1610
|
}, {});
|
|
1611
1611
|
});
|
|
1612
|
-
const documentationBundleHook = (bundle, config) => __async$
|
|
1612
|
+
const documentationBundleHook = (bundle, config) => __async$4(void 0, null, function* () {
|
|
1613
1613
|
return {
|
|
1614
1614
|
referenceGuide: yield transformReferenceGuide(bundle.referenceGuide, config.transformReferenceGuide),
|
|
1615
1615
|
docs: yield transformDocs(bundle.docs, config.transformDocs, config.transformDocPage)
|
|
1616
1616
|
};
|
|
1617
1617
|
});
|
|
1618
|
-
const transformReferenceGuide = (_0, ..._1) => __async$
|
|
1618
|
+
const transformReferenceGuide = (_0, ..._1) => __async$4(void 0, [_0, ..._1], function* (referenceGuide, hook = passThroughHook) {
|
|
1619
1619
|
const result = yield hook(referenceGuide);
|
|
1620
1620
|
if (isSkip(result)) {
|
|
1621
1621
|
return result;
|
|
1622
1622
|
}
|
|
1623
1623
|
return __spreadValues$7(__spreadValues$7({}, referenceGuide), yield hook(referenceGuide));
|
|
1624
1624
|
});
|
|
1625
|
-
const transformDocs = (_0, ..._1) => __async$
|
|
1625
|
+
const transformDocs = (_0, ..._1) => __async$4(void 0, [_0, ..._1], function* (docs, transformDocsHook = passThroughHook, transformDocPageHook = passThroughHook) {
|
|
1626
1626
|
const transformed = yield transformDocsHook(docs);
|
|
1627
1627
|
return Promise.all(transformed.map((doc) => transformDocPage(doc, transformDocPageHook)));
|
|
1628
1628
|
});
|
|
1629
|
-
const transformDocPage = (_0, ..._1) => __async$
|
|
1629
|
+
const transformDocPage = (_0, ..._1) => __async$4(void 0, [_0, ..._1], function* (doc, hook = passThroughHook) {
|
|
1630
1630
|
return __spreadValues$7(__spreadValues$7({}, doc), yield hook(doc));
|
|
1631
1631
|
});
|
|
1632
1632
|
function postHookCompile(bundle) {
|
|
@@ -2797,47 +2797,134 @@ function filterByScopes(manifest) {
|
|
|
2797
2797
|
return filteredTypes;
|
|
2798
2798
|
}
|
|
2799
2799
|
|
|
2800
|
+
var __async$3 = (__this, __arguments, generator) => {
|
|
2801
|
+
return new Promise((resolve, reject) => {
|
|
2802
|
+
var fulfilled = (value) => {
|
|
2803
|
+
try {
|
|
2804
|
+
step(generator.next(value));
|
|
2805
|
+
} catch (e) {
|
|
2806
|
+
reject(e);
|
|
2807
|
+
}
|
|
2808
|
+
};
|
|
2809
|
+
var rejected = (value) => {
|
|
2810
|
+
try {
|
|
2811
|
+
step(generator.throw(value));
|
|
2812
|
+
} catch (e) {
|
|
2813
|
+
reject(e);
|
|
2814
|
+
}
|
|
2815
|
+
};
|
|
2816
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
2817
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
2818
|
+
});
|
|
2819
|
+
};
|
|
2800
2820
|
const APEX_FILE_EXTENSION = ".cls";
|
|
2801
2821
|
class ApexFileReader {
|
|
2802
2822
|
/**
|
|
2803
2823
|
* Reads from .cls files and returns their raw body.
|
|
2804
2824
|
*/
|
|
2805
2825
|
static processFiles(fileSystem, rootPath, includeMetadata) {
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
const
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2826
|
+
return __async$3(this, null, function* () {
|
|
2827
|
+
const filePaths = yield this.getFilePaths(fileSystem, rootPath);
|
|
2828
|
+
const apexFilePaths = filePaths.filter((filePath) => this.isApexFile(filePath));
|
|
2829
|
+
const filePromises = apexFilePaths.map((filePath) => this.processFile(fileSystem, filePath, includeMetadata));
|
|
2830
|
+
return Promise.all(filePromises);
|
|
2831
|
+
});
|
|
2832
|
+
}
|
|
2833
|
+
static getFilePaths(fileSystem, rootPath) {
|
|
2834
|
+
return __async$3(this, null, function* () {
|
|
2835
|
+
const directoryContents = yield fileSystem.readDirectory(rootPath);
|
|
2836
|
+
const paths = [];
|
|
2837
|
+
for (const filePath of directoryContents) {
|
|
2838
|
+
const currentPath = fileSystem.joinPath(rootPath, filePath);
|
|
2839
|
+
if (yield fileSystem.isDirectory(currentPath)) {
|
|
2840
|
+
paths.push(...yield this.getFilePaths(fileSystem, currentPath));
|
|
2841
|
+
}
|
|
2842
|
+
paths.push(currentPath);
|
|
2815
2843
|
}
|
|
2816
|
-
|
|
2817
|
-
|
|
2844
|
+
return paths;
|
|
2845
|
+
});
|
|
2846
|
+
}
|
|
2847
|
+
static processFile(fileSystem, filePath, includeMetadata) {
|
|
2848
|
+
return __async$3(this, null, function* () {
|
|
2849
|
+
const rawTypeContent = yield fileSystem.readFile(filePath);
|
|
2850
|
+
const metadataPath = `${filePath}-meta.xml`;
|
|
2818
2851
|
let rawMetadataContent = null;
|
|
2819
2852
|
if (includeMetadata) {
|
|
2820
|
-
rawMetadataContent = fileSystem.exists(metadataPath) ? fileSystem.readFile(metadataPath) : null;
|
|
2853
|
+
rawMetadataContent = fileSystem.exists(metadataPath) ? yield fileSystem.readFile(metadataPath) : null;
|
|
2821
2854
|
}
|
|
2822
|
-
|
|
2855
|
+
return { filePath, content: rawTypeContent, metadataContent: rawMetadataContent };
|
|
2823
2856
|
});
|
|
2824
|
-
return bundles;
|
|
2825
2857
|
}
|
|
2826
2858
|
static isApexFile(currentFile) {
|
|
2827
2859
|
return currentFile.endsWith(APEX_FILE_EXTENSION);
|
|
2828
2860
|
}
|
|
2829
2861
|
}
|
|
2830
2862
|
|
|
2863
|
+
var __async$2 = (__this, __arguments, generator) => {
|
|
2864
|
+
return new Promise((resolve, reject) => {
|
|
2865
|
+
var fulfilled = (value) => {
|
|
2866
|
+
try {
|
|
2867
|
+
step(generator.next(value));
|
|
2868
|
+
} catch (e) {
|
|
2869
|
+
reject(e);
|
|
2870
|
+
}
|
|
2871
|
+
};
|
|
2872
|
+
var rejected = (value) => {
|
|
2873
|
+
try {
|
|
2874
|
+
step(generator.throw(value));
|
|
2875
|
+
} catch (e) {
|
|
2876
|
+
reject(e);
|
|
2877
|
+
}
|
|
2878
|
+
};
|
|
2879
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
2880
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
2881
|
+
});
|
|
2882
|
+
};
|
|
2883
|
+
function stat(path2) {
|
|
2884
|
+
return new Promise((resolve, reject) => {
|
|
2885
|
+
fs__namespace.stat(path2, (err, stats) => {
|
|
2886
|
+
if (err) {
|
|
2887
|
+
reject(err);
|
|
2888
|
+
} else {
|
|
2889
|
+
resolve(stats);
|
|
2890
|
+
}
|
|
2891
|
+
});
|
|
2892
|
+
});
|
|
2893
|
+
}
|
|
2894
|
+
function readdir(path2) {
|
|
2895
|
+
return new Promise((resolve, reject) => {
|
|
2896
|
+
fs__namespace.readdir(path2, (err, files) => {
|
|
2897
|
+
if (err) {
|
|
2898
|
+
reject(err);
|
|
2899
|
+
} else {
|
|
2900
|
+
resolve(files);
|
|
2901
|
+
}
|
|
2902
|
+
});
|
|
2903
|
+
});
|
|
2904
|
+
}
|
|
2905
|
+
function readFile(path2) {
|
|
2906
|
+
return new Promise((resolve, reject) => {
|
|
2907
|
+
fs__namespace.readFile(path2, (err, data) => {
|
|
2908
|
+
if (err) {
|
|
2909
|
+
reject(err);
|
|
2910
|
+
} else {
|
|
2911
|
+
resolve(data.toString());
|
|
2912
|
+
}
|
|
2913
|
+
});
|
|
2914
|
+
});
|
|
2915
|
+
}
|
|
2831
2916
|
class DefaultFileSystem {
|
|
2832
2917
|
isDirectory(pathToRead) {
|
|
2833
|
-
return
|
|
2918
|
+
return __async$2(this, null, function* () {
|
|
2919
|
+
const stats = yield stat(pathToRead);
|
|
2920
|
+
return stats.isDirectory();
|
|
2921
|
+
});
|
|
2834
2922
|
}
|
|
2835
2923
|
readDirectory(sourceDirectory) {
|
|
2836
|
-
return
|
|
2924
|
+
return readdir(sourceDirectory);
|
|
2837
2925
|
}
|
|
2838
2926
|
readFile(pathToRead) {
|
|
2839
|
-
|
|
2840
|
-
return rawFile.toString();
|
|
2927
|
+
return readFile(pathToRead);
|
|
2841
2928
|
}
|
|
2842
2929
|
joinPath(...paths) {
|
|
2843
2930
|
return path__namespace.join(...paths);
|
|
@@ -2875,7 +2962,11 @@ class Apexdocs {
|
|
|
2875
2962
|
return __async$1(this, null, function* () {
|
|
2876
2963
|
Logger.logSingle(`Generating ${config.targetGenerator} documentation...`);
|
|
2877
2964
|
try {
|
|
2878
|
-
const fileBodies = ApexFileReader.processFiles(
|
|
2965
|
+
const fileBodies = yield ApexFileReader.processFiles(
|
|
2966
|
+
new DefaultFileSystem(),
|
|
2967
|
+
config.sourceDir,
|
|
2968
|
+
config.includeMetadata
|
|
2969
|
+
);
|
|
2879
2970
|
switch (config.targetGenerator) {
|
|
2880
2971
|
case "markdown":
|
|
2881
2972
|
yield generate(fileBodies, config);
|
package/package.json
CHANGED
|
@@ -17,7 +17,11 @@ export class Apexdocs {
|
|
|
17
17
|
Logger.logSingle(`Generating ${config.targetGenerator} documentation...`);
|
|
18
18
|
|
|
19
19
|
try {
|
|
20
|
-
const fileBodies = ApexFileReader.processFiles(
|
|
20
|
+
const fileBodies = await ApexFileReader.processFiles(
|
|
21
|
+
new DefaultFileSystem(),
|
|
22
|
+
config.sourceDir,
|
|
23
|
+
config.includeMetadata,
|
|
24
|
+
);
|
|
21
25
|
|
|
22
26
|
switch (config.targetGenerator) {
|
|
23
27
|
case 'markdown':
|
|
@@ -18,24 +18,24 @@ describe('File Reader', () => {
|
|
|
18
18
|
} as SettingsConfig);
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
it('returns an empty list when there are no files in the directory', () => {
|
|
22
|
-
const result = ApexFileReader.processFiles(
|
|
21
|
+
it('returns an empty list when there are no files in the directory', async () => {
|
|
22
|
+
const result = await ApexFileReader.processFiles(
|
|
23
23
|
{
|
|
24
24
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
25
|
-
isDirectory(_: string): boolean {
|
|
26
|
-
return false;
|
|
25
|
+
isDirectory(_: string): Promise<boolean> {
|
|
26
|
+
return Promise.resolve(false);
|
|
27
27
|
},
|
|
28
28
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
29
29
|
joinPath(_: string): string {
|
|
30
30
|
return '';
|
|
31
31
|
},
|
|
32
32
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
-
readDirectory(_: string): string[] {
|
|
34
|
-
return [];
|
|
33
|
+
readDirectory(_: string): Promise<string[]> {
|
|
34
|
+
return Promise.resolve([]);
|
|
35
35
|
},
|
|
36
36
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
37
|
-
readFile(_: string): string {
|
|
38
|
-
return '';
|
|
37
|
+
readFile(_: string): Promise<string> {
|
|
38
|
+
return Promise.resolve('');
|
|
39
39
|
},
|
|
40
40
|
exists(): boolean {
|
|
41
41
|
return true;
|
|
@@ -47,20 +47,20 @@ describe('File Reader', () => {
|
|
|
47
47
|
expect(result.length).toBe(0);
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
it('returns an empty list when there are no Apex files in the directory', () => {
|
|
51
|
-
const result = ApexFileReader.processFiles(
|
|
50
|
+
it('returns an empty list when there are no Apex files in the directory', async () => {
|
|
51
|
+
const result = await ApexFileReader.processFiles(
|
|
52
52
|
{
|
|
53
|
-
isDirectory(): boolean {
|
|
54
|
-
return false;
|
|
53
|
+
isDirectory(): Promise<boolean> {
|
|
54
|
+
return Promise.resolve(false);
|
|
55
55
|
},
|
|
56
56
|
joinPath(): string {
|
|
57
57
|
return '';
|
|
58
58
|
},
|
|
59
|
-
readDirectory(): string[] {
|
|
60
|
-
return ['SomeFile.md'];
|
|
59
|
+
readDirectory(): Promise<string[]> {
|
|
60
|
+
return Promise.resolve(['SomeFile.md']);
|
|
61
61
|
},
|
|
62
|
-
readFile(): string {
|
|
63
|
-
return '';
|
|
62
|
+
readFile(): Promise<string> {
|
|
63
|
+
return Promise.resolve('');
|
|
64
64
|
},
|
|
65
65
|
exists(): boolean {
|
|
66
66
|
return true;
|
|
@@ -72,24 +72,24 @@ describe('File Reader', () => {
|
|
|
72
72
|
expect(result.length).toBe(0);
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
-
it('returns the file contents for an Apex file', () => {
|
|
76
|
-
const result = ApexFileReader.processFiles(
|
|
75
|
+
it('returns the file contents for an Apex file', async () => {
|
|
76
|
+
const result = await ApexFileReader.processFiles(
|
|
77
77
|
{
|
|
78
78
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
79
|
-
isDirectory(_: string): boolean {
|
|
80
|
-
return false;
|
|
79
|
+
isDirectory(_: string): Promise<boolean> {
|
|
80
|
+
return Promise.resolve(false);
|
|
81
81
|
},
|
|
82
82
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
83
83
|
joinPath(_: string): string {
|
|
84
|
-
return '';
|
|
84
|
+
return 'SomeApexFile.cls';
|
|
85
85
|
},
|
|
86
86
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
87
|
-
readDirectory(_: string): string[] {
|
|
88
|
-
return ['SomeApexFile.cls'];
|
|
87
|
+
readDirectory(_: string): Promise<string[]> {
|
|
88
|
+
return Promise.resolve(['SomeApexFile.cls']);
|
|
89
89
|
},
|
|
90
90
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
91
|
-
readFile(_: string): string {
|
|
92
|
-
return 'public class MyClass{}';
|
|
91
|
+
readFile(_: string): Promise<string> {
|
|
92
|
+
return Promise.resolve('public class MyClass{}');
|
|
93
93
|
},
|
|
94
94
|
exists(): boolean {
|
|
95
95
|
return true;
|
|
@@ -10,30 +10,43 @@ export class ApexFileReader {
|
|
|
10
10
|
/**
|
|
11
11
|
* Reads from .cls files and returns their raw body.
|
|
12
12
|
*/
|
|
13
|
-
static processFiles(
|
|
14
|
-
|
|
13
|
+
static async processFiles(
|
|
14
|
+
fileSystem: FileSystem,
|
|
15
|
+
rootPath: string,
|
|
16
|
+
includeMetadata: boolean,
|
|
17
|
+
): Promise<UnparsedSourceFile[]> {
|
|
18
|
+
const filePaths = await this.getFilePaths(fileSystem, rootPath);
|
|
19
|
+
const apexFilePaths = filePaths.filter((filePath) => this.isApexFile(filePath));
|
|
20
|
+
const filePromises = apexFilePaths.map((filePath) => this.processFile(fileSystem, filePath, includeMetadata));
|
|
21
|
+
return Promise.all(filePromises);
|
|
22
|
+
}
|
|
15
23
|
|
|
16
|
-
|
|
17
|
-
directoryContents.
|
|
24
|
+
private static async getFilePaths(fileSystem: FileSystem, rootPath: string): Promise<string[]> {
|
|
25
|
+
const directoryContents = await fileSystem.readDirectory(rootPath);
|
|
26
|
+
const paths: string[] = [];
|
|
27
|
+
for (const filePath of directoryContents) {
|
|
18
28
|
const currentPath = fileSystem.joinPath(rootPath, filePath);
|
|
19
|
-
if (fileSystem.isDirectory(currentPath)) {
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (!this.isApexFile(filePath)) {
|
|
24
|
-
return;
|
|
29
|
+
if (await fileSystem.isDirectory(currentPath)) {
|
|
30
|
+
paths.push(...(await this.getFilePaths(fileSystem, currentPath)));
|
|
25
31
|
}
|
|
32
|
+
paths.push(currentPath);
|
|
33
|
+
}
|
|
34
|
+
return paths;
|
|
35
|
+
}
|
|
26
36
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
private static async processFile(
|
|
38
|
+
fileSystem: FileSystem,
|
|
39
|
+
filePath: string,
|
|
40
|
+
includeMetadata: boolean,
|
|
41
|
+
): Promise<UnparsedSourceFile> {
|
|
42
|
+
const rawTypeContent = await fileSystem.readFile(filePath);
|
|
43
|
+
const metadataPath = `${filePath}-meta.xml`;
|
|
44
|
+
let rawMetadataContent = null;
|
|
45
|
+
if (includeMetadata) {
|
|
46
|
+
rawMetadataContent = fileSystem.exists(metadataPath) ? await fileSystem.readFile(metadataPath) : null;
|
|
47
|
+
}
|
|
33
48
|
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
return bundles;
|
|
49
|
+
return { filePath, content: rawTypeContent, metadataContent: rawMetadataContent };
|
|
37
50
|
}
|
|
38
51
|
|
|
39
52
|
private static isApexFile(currentFile: string): boolean {
|
|
@@ -2,25 +2,61 @@ import * as fs from 'fs';
|
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
|
|
4
4
|
export interface FileSystem {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
readFile: (path: string) => string
|
|
5
|
+
isDirectory: (path: string) => Promise<boolean>;
|
|
6
|
+
readDirectory: (sourceDirectory: string) => Promise<string[]>;
|
|
7
|
+
readFile: (path: string) => Promise<string>;
|
|
8
8
|
joinPath: (...paths: string[]) => string;
|
|
9
9
|
exists: (path: string) => boolean;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
function stat(path: string): Promise<fs.Stats> {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
fs.stat(path, (err, stats) => {
|
|
15
|
+
if (err) {
|
|
16
|
+
reject(err);
|
|
17
|
+
} else {
|
|
18
|
+
resolve(stats);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function readdir(path: string): Promise<string[]> {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
fs.readdir(path, (err, files) => {
|
|
27
|
+
if (err) {
|
|
28
|
+
reject(err);
|
|
29
|
+
} else {
|
|
30
|
+
resolve(files);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function readFile(path: string): Promise<string> {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
fs.readFile(path, (err, data) => {
|
|
39
|
+
if (err) {
|
|
40
|
+
reject(err);
|
|
41
|
+
} else {
|
|
42
|
+
resolve(data.toString());
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
12
48
|
export class DefaultFileSystem implements FileSystem {
|
|
13
|
-
isDirectory(pathToRead: string): boolean {
|
|
14
|
-
|
|
49
|
+
async isDirectory(pathToRead: string): Promise<boolean> {
|
|
50
|
+
const stats = await stat(pathToRead);
|
|
51
|
+
return stats.isDirectory();
|
|
15
52
|
}
|
|
16
53
|
|
|
17
|
-
readDirectory(sourceDirectory: string): string[] {
|
|
18
|
-
return
|
|
54
|
+
readDirectory(sourceDirectory: string): Promise<string[]> {
|
|
55
|
+
return readdir(sourceDirectory);
|
|
19
56
|
}
|
|
20
57
|
|
|
21
|
-
readFile(pathToRead: string): string {
|
|
22
|
-
|
|
23
|
-
return rawFile.toString();
|
|
58
|
+
readFile(pathToRead: string): Promise<string> {
|
|
59
|
+
return readFile(pathToRead);
|
|
24
60
|
}
|
|
25
61
|
|
|
26
62
|
joinPath(...paths: string[]): string {
|