@awesomeness-js/utils 1.0.0 → 1.0.1
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/index.js +8 -8
- package/package.json +1 -1
- package/src/build.js +11 -2
package/index.js
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
* It consolidates API functions for use in the application.
|
|
4
4
|
* Do not edit manually.
|
|
5
5
|
*/
|
|
6
|
-
import _build from './build.js';
|
|
6
|
+
import _build from './src/build.js';
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
|
-
/**
|
|
10
|
-
* Generates a output file that consolidates all src functions.
|
|
11
|
-
*
|
|
12
|
-
* @param {Object} [options] - The options for generating the output file.
|
|
13
|
-
* @param {string} [options.src='./src'] - The source directory.
|
|
14
|
-
* @param {array} [options.dest=['./', 'index.js']] - The destination file.
|
|
15
|
-
* @returns {bool} - Returns true if the output file is generated successfully.
|
|
9
|
+
/**
|
|
10
|
+
* Generates a output file that consolidates all src functions.
|
|
11
|
+
*
|
|
12
|
+
* @param {Object} [options] - The options for generating the output file.
|
|
13
|
+
* @param {string} [options.src='./src'] - The source directory.
|
|
14
|
+
* @param {array} [options.dest=['./', 'index.js']] - The destination file.
|
|
15
|
+
* @returns {bool} - Returns true if the output file is generated successfully.
|
|
16
16
|
*/
|
|
17
17
|
build: _build
|
|
18
18
|
};
|
package/package.json
CHANGED
package/src/build.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readdirSync, statSync, writeFileSync, readFileSync } from 'fs';
|
|
2
|
-
import { join, sep } from 'path';
|
|
2
|
+
import { dirname, join, sep } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Generates a output file that consolidates all src functions.
|
|
@@ -10,6 +11,14 @@ import { join, sep } from 'path';
|
|
|
10
11
|
* @returns {bool} - Returns true if the output file is generated successfully.
|
|
11
12
|
*/
|
|
12
13
|
|
|
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
|
function getAllFiles(base, dir, files = []) {
|
|
14
23
|
const directory = join(base, dir);
|
|
15
24
|
let sortedFiles = readdirSync(directory).sort();
|
|
@@ -78,7 +87,7 @@ function generateExports(src) {
|
|
|
78
87
|
const parts = file.split(sep).filter(p => p !== '.');
|
|
79
88
|
const functionName = parts.pop().replace('.js', '');
|
|
80
89
|
const namespace = parts.join('_');
|
|
81
|
-
const importPath = '
|
|
90
|
+
const importPath = src + '/' + file.replace(/\.js$/, '').replace(/\\/g, '/');
|
|
82
91
|
const filePath = join(src, file);
|
|
83
92
|
|
|
84
93
|
// Extract JSDoc comment, if present
|