Skip to content

Commit b668bd3

Browse files
SamuelRobertoVincenzo Anniciello
authored and
Vincenzo Anniciello
committed
feat: added support to copy directories
1 parent 97ac51b commit b668bd3

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"build": "rm -rf dist && npx tsx src/cli.ts build",
2626
"lint": "eslint ./src --ext .ts --config .eslintrc",
2727
"lint:fix": "npm run lint -- --fix",
28-
"lint:beautify": "npm run lint:fix && prettier ./src --write"
28+
"lint:beautify": "npm run lint:fix && prettier ./src --write",
29+
"release": "npx @futura-dev/cosmodrome release"
2930
},
3031
"dependencies": {
3132
"@commitlint/config-conventional": "^17.6.3",

Diff for: src/commands/build.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export const build = async (): Promise<void> => {
112112
const srcDir = "./src";
113113
const distDir = `${initWithDotSlash(tsConfig.compilerOptions.outDir)}`;
114114

115-
const compilerOptions: ts.CompilerOptions = tsConfig.compilerOptions;
115+
const compilerOptions: ts.CompilerOptions = ts.convertCompilerOptionsFromJson(tsConfig.compilerOptions, '').options;
116116

117117
// Create the output directory if it doesn't exist
118118
if (!fs.existsSync(distDir)) {
@@ -157,25 +157,26 @@ export const build = async (): Promise<void> => {
157157

158158
// Copy files to the output directory
159159
for (const source of Object.keys(configuration.files)) {
160-
if (!fs.existsSync(source) || fs.lstatSync(source).isDirectory()) {
160+
if (!fs.existsSync(source)) {
161161
throw new Error(
162-
`🧨⚠️💣 Source ${source} does not exist or is a directory`
162+
`🧨⚠️💣 Source ${source} does not exist`
163163
);
164164
}
165165

166166
const destination = `${distDir}/${configuration.files[source]}`;
167167
const sourceFileName = source.split("/").pop();
168168

169-
const { fileName: destinationDileName, directory } =
169+
const { fileName: destinationFileName, directory } =
170170
pathToWriteOptions(destination);
171171

172-
fs.mkdirSync(directory, { recursive: true });
173-
174172
fs.cpSync(
175173
source,
176-
destinationDileName
177-
? `${directory}/${destinationDileName}`
178-
: `${directory}/${sourceFileName}`
174+
destinationFileName
175+
? `${directory}/${destinationFileName}`
176+
: `${directory}/${sourceFileName}`,
177+
{
178+
recursive: true
179+
}
179180
);
180181
}
181182

0 commit comments

Comments
 (0)