Skip to content

Commit b7f0f65

Browse files
committed
feat(cgi-bin): build and deploy JS files from the cgi-bin folder
fixes #436
1 parent 00c1503 commit b7f0f65

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/deploy.cmd.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,13 @@ class DeployCommand extends AbstractCommand {
134134
}
135135

136136
actionName(script) {
137+
console.log(script.main);
137138
if (script.main.indexOf(path.resolve(__dirname, 'openwhisk')) === 0) {
138139
return `hlx--${script.name}`;
139140
}
141+
if (script.main.match(/cgi-bin\//)) {
142+
return `${this._prefix}/cgi-bin-${script.name}`;
143+
}
140144
return `${this._prefix}/${script.name}`;
141145
}
142146

@@ -331,7 +335,7 @@ Alternatively you can auto-add one using the {grey --add <name>} option.`);
331335
}
332336

333337
// get the list of scripts from the info files
334-
const infos = [...glob.sync(`${this._target}/*.info.json`)];
338+
const infos = [...glob.sync(`${this._target}/**/*.info.json`)];
335339
const scriptInfos = await Promise.all(infos.map(info => fs.readJSON(info)));
336340
const scripts = scriptInfos.filter(script => script.zipFile);
337341

src/package.cmd.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,11 @@ class PackageCommand extends AbstractCommand {
194194
scripts.forEach((script) => {
195195
/* eslint-disable no-param-reassign */
196196
script.name = path.basename(script.main, '.js');
197+
script.dirname = script.isStatic ? '' : path.dirname(script.main);
198+
console.log(script.name, script.dirname);
197199
script.archiveName = `${script.name}.zip`;
198-
script.zipFile = path.resolve(this._target, script.archiveName);
199-
script.infoFile = path.resolve(this._target, `${script.name}.info.json`);
200+
script.zipFile = path.resolve(this._target, script.dirname, script.archiveName);
201+
script.infoFile = path.resolve(this._target, script.dirname, `${script.name}.info.json`);
200202
/* eslint-enable no-param-reassign */
201203
});
202204

src/yargs-build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = function commonArgs(yargs) {
2929
})
3030
.positional('files', {
3131
describe: 'The template files to compile',
32-
default: ['src/**/*.htl', 'src/**/*.js'],
32+
default: ['src/**/*.htl', 'src/**/*.js', 'cgi-bin/**/*.js'],
3333
array: true,
3434
type: 'string',
3535
})

0 commit comments

Comments
 (0)