Skip to content

Commit

Permalink
fix: guard “example” directory and LICENSE during module build (#13591)
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn committed Oct 7, 2022
1 parent fca30fd commit 95deb4e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions iphone/cli/commands/_buildModule.js
Expand Up @@ -904,9 +904,11 @@ iOSModuleBuilder.prototype.packageModule = function packageModule(next) {
}

// 2. example folder
this.dirWalker(this.exampleDir, function (file) {
dest.append(fs.createReadStream(file), { name: path.join(moduleFolders, 'example', path.relative(this.exampleDir, file)) });
}.bind(this));
if (fs.existsSync(this.exampleDir)) {
this.dirWalker(this.exampleDir, function (file) {
dest.append(fs.createReadStream(file), { name: path.join(moduleFolders, 'example', path.relative(this.exampleDir, file)) });
}.bind(this));
}

// 3. platform folder
if (fs.existsSync(this.platformDir)) {
Expand Down Expand Up @@ -959,7 +961,11 @@ iOSModuleBuilder.prototype.packageModule = function packageModule(next) {
dest.directory(binarylibFile, path.join(moduleFolders, binarylibName));

// 8. LICENSE file
dest.append(fs.createReadStream(this.licenseFile), { name: path.join(moduleFolders, 'LICENSE') });
if (fs.existsSync(this.licenseFile)) {
dest.append(fs.createReadStream(this.licenseFile), { name: path.join(moduleFolders, 'LICENSE') });
} else {
this.logger.warn(__('Missing LICENSE file in the module\'s project root. We recommend to include the file to ensure proper OSS compliance.'));
}

// 9. manifest
dest.append(fs.createReadStream(this.manifestFile), { name: path.join(moduleFolders, 'manifest') });
Expand Down

0 comments on commit 95deb4e

Please sign in to comment.