Skip to content

Commit dedc2b9

Browse files
committed
Throw error if source and compiled dirs are the same
1 parent f504b42 commit dedc2b9

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Diff for: lib/build.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ function webpackConfig(dir, additionalConfig) {
2222
];
2323
}
2424

25+
var functionsDir = config.build.functions || config.build.Functions;
26+
var functionsPath = path.join(process.cwd(), functionsDir);
27+
var dirPath = path.join(process.cwd(), dir);
28+
29+
if (dirPath === functionsPath) {
30+
throw new Error("Function source directory and compiled directory are the same");
31+
}
32+
2533
var webpackConfig = {
2634
module: {
2735
rules: [
@@ -35,21 +43,18 @@ function webpackConfig(dir, additionalConfig) {
3543
}
3644
]
3745
},
38-
context: path.join(process.cwd(), dir),
46+
context: dirPath,
3947
entry: {},
4048
target: "node",
4149
plugins: [new webpack.IgnorePlugin(/vertx/)],
4250
output: {
43-
path: path.join(
44-
process.cwd(),
45-
config.build.functions || config.build.Functions
46-
),
51+
path: functionsPath,
4752
filename: "[name].js",
4853
libraryTarget: "commonjs"
4954
},
5055
devtool: false
5156
};
52-
fs.readdirSync(path.join(process.cwd(), dir)).forEach(function(file) {
57+
fs.readdirSync(dirPath).forEach(function(file) {
5358
if (file.match(/\.js$/)) {
5459
var name = file.replace(/\.js$/, "");
5560
webpackConfig.entry[name] = "./" + name;

0 commit comments

Comments
 (0)