@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 CHANGED
@@ -2,5 +2,5 @@ import build from './src/build.js';
2
2
 
3
3
  build({
4
4
  src: './src',
5
- dest: ['./', 'index.js']
5
+ dest: './index.js'
6
6
  });
package/index.js CHANGED
@@ -5,6 +5,8 @@
5
5
  */
6
6
  import _build from './src/build.js';
7
7
 
8
+ export { _build as build };
9
+
8
10
  export default {
9
11
  /**
10
12
  * Generates a output file that consolidates all src functions.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awesomeness-js/utils",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Awesomeness - Utils",
5
5
  "repository": {
6
6
  "type": "git",
package/src/build.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { readdirSync, statSync, writeFileSync, readFileSync } from 'fs';
2
- import { dirname, join, sep } from 'path';
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 = ['./', 'index.js']
126
+ dest = './index.js'
131
127
  } = {}) {
132
128
  const indexContent = generateExports(src);
133
- writeFileSync(join(...dest), indexContent);
129
+ writeFileSync(dest, indexContent);
134
130
  return true;
135
131
  }
136
132