Skip to content

Commit 4beed21

Browse files
author
Theryston
committed
fix: file indexing issue in subfolders
1 parent 116317d commit 4beed21

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

packages/core/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @jsx-mail/core
22

3+
## 1.0.4
4+
5+
### Patch Changes
6+
7+
- fixing file indexing issue in subfolders
8+
39
## 1.0.3
410

511
### Patch Changes

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.0.3",
2+
"version": "1.0.4",
33
"license": "MIT",
44
"description": "All jsx mail core functions. 🚀✉️",
55
"main": "dist/index.js",

packages/core/src/implementations/FileSystem/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ import { IDirectoryTree, IFileSystem, IFileSystemOptions } from './IFileSystem';
33
import path from 'path';
44

55
export class FileSystem implements IFileSystem {
6+
private getAllDirectoryTree_firstBase: string;
7+
68
async getAllDirectoryTree(
79
basePath: string,
810
options?: IFileSystemOptions
911
): Promise<IDirectoryTree[]> {
12+
if (!this.getAllDirectoryTree_firstBase) {
13+
this.getAllDirectoryTree_firstBase = basePath;
14+
}
15+
1016
const { justFilenameInFilePath = false, fileExtensions = [] } =
1117
options || {};
1218

@@ -31,7 +37,10 @@ export class FileSystem implements IFileSystem {
3137
) {
3238
directoryTree.push({
3339
children: [],
34-
path: path.basename(entityPath),
40+
path: path.relative(
41+
this.getAllDirectoryTree_firstBase,
42+
entityPath
43+
),
3544
type: 'file',
3645
});
3746
}

packages/core/src/implementations/JsxTransform/index.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { IFileSystem } from '../FileSystem/IFileSystem';
33
import { IJsxTransform, IJsxTransformOptions } from './IJsxTransform';
44
import path from 'path';
55

6+
const DEFAULT_DELETE_FOLDERS = ['dist'];
7+
68
export class JsxTransform implements IJsxTransform {
79
private firstAbsoluteSourcePath: string;
810

@@ -21,6 +23,16 @@ export class JsxTransform implements IJsxTransform {
2123
await this.fileSystem.rm(path.join(sourcePath, outputDir));
2224
}
2325

26+
for (const DEFAULT_DELETE_FOLDER of DEFAULT_DELETE_FOLDERS) {
27+
if (
28+
await this.fileSystem.exists(
29+
path.join(sourcePath, DEFAULT_DELETE_FOLDER)
30+
)
31+
) {
32+
await this.fileSystem.rm(path.join(sourcePath, DEFAULT_DELETE_FOLDER));
33+
}
34+
}
35+
2436
const entities = await this.fileSystem.getAllDirectoryTree(sourcePath, {
2537
justFilenameInFilePath: true,
2638
fileExtensions: ['ts', 'js', 'jsx', 'tsx'],
@@ -32,7 +44,7 @@ export class JsxTransform implements IJsxTransform {
3244
await this.directory(child.path, outputDir);
3345
} else {
3446
await this.file(
35-
child.path,
47+
path.join(sourcePath, child.path),
3648
path.join(this.firstAbsoluteSourcePath, outputDir),
3749
options
3850
);

0 commit comments

Comments
 (0)