@awesomeness-js/utils 1.0.1 → 1.0.3
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/build.js +1 -1
- package/index.js +2 -0
- package/package.json +1 -1
- package/src/build.js +8 -12
package/build.js
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
package/src/build.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { readdirSync, statSync, writeFileSync, readFileSync } from 'fs';
|
|
2
|
-
import {
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
2
|
+
import { join, sep } from 'path';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Generates a output file that consolidates all src functions.
|
|
@@ -11,13 +10,6 @@ import { fileURLToPath } from 'url';
|
|
|
11
10
|
* @returns {bool} - Returns true if the output file is generated successfully.
|
|
12
11
|
*/
|
|
13
12
|
|
|
14
|
-
// Resolve __dirname equivalent for ES Modules
|
|
15
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
-
const __dirname = dirname(__filename);
|
|
17
|
-
|
|
18
|
-
function resolvePath(relativePath) {
|
|
19
|
-
return join(__dirname, relativePath);
|
|
20
|
-
}
|
|
21
13
|
|
|
22
14
|
function getAllFiles(base, dir, files = []) {
|
|
23
15
|
const directory = join(base, dir);
|
|
@@ -78,6 +70,7 @@ function generateExports(src) {
|
|
|
78
70
|
allFiles.push(...fnFiles);
|
|
79
71
|
|
|
80
72
|
let imports = '';
|
|
73
|
+
let allExports = '';
|
|
81
74
|
let apiObject = {};
|
|
82
75
|
|
|
83
76
|
let allComments = {};
|
|
@@ -102,6 +95,9 @@ function generateExports(src) {
|
|
|
102
95
|
// Generate import statement with JSDoc comment if available
|
|
103
96
|
imports += `import ${namespace}_${functionName} from '${importPath}.js';\n`;
|
|
104
97
|
|
|
98
|
+
// generate exports
|
|
99
|
+
if(!namespace){ allExports += `export { _${functionName} as ${functionName} };\n`; }
|
|
100
|
+
|
|
105
101
|
// Populate the API object structure
|
|
106
102
|
let current = apiObject;
|
|
107
103
|
for (const part of parts) {
|
|
@@ -121,16 +117,16 @@ function generateExports(src) {
|
|
|
121
117
|
*/
|
|
122
118
|
`;
|
|
123
119
|
|
|
124
|
-
return headerComment + imports + '\n' + apiContent;
|
|
120
|
+
return headerComment + imports + '\n' + allExports + '\n' + apiContent;
|
|
125
121
|
}
|
|
126
122
|
|
|
127
123
|
|
|
128
124
|
async function build({
|
|
129
125
|
src = './src',
|
|
130
|
-
dest =
|
|
126
|
+
dest = './index.js'
|
|
131
127
|
} = {}) {
|
|
132
128
|
const indexContent = generateExports(src);
|
|
133
|
-
writeFileSync(
|
|
129
|
+
writeFileSync(dest, indexContent);
|
|
134
130
|
return true;
|
|
135
131
|
}
|
|
136
132
|
|