From 98b690d4ab042a1e3a51469aa18da11ea6f1d26f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=B5=E6=97=AD?= Date: Sat, 16 Nov 2019 00:45:09 +0800 Subject: [PATCH 1/4] refactor: ignore hidden files or directories when list charts directory. https://stackoverflow.com/questions/31999691/how-can-i-exclude-a-directory-from-ls-command --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 5523401..705b28d 100644 --- a/index.js +++ b/index.js @@ -60,7 +60,7 @@ async function run() { const chartDirectories = getDirectories(path.resolve(`./${chartsDir}`)); console.log('Charts dir content'); - await exec.exec(`ls`, [], { cwd: `./${chartsDir}` }); + await exec.exec(`ls`, ['-I ".*"'], { cwd: `./${chartsDir}` }); for (const chartDirname of chartDirectories) { console.log(`Packaging helm chart in directory ${chartDirname}`); await exec.exec( From f8c272aef0103df4f2a0eadcdda2b59305ca30dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=B5=E6=97=AD?= Date: Sat, 16 Nov 2019 00:49:33 +0800 Subject: [PATCH 2/4] feat: add helm dependency update before packaging. https://stackoverflow.com/questions/20643470/execute-a-command-line-binary-with-node-js I am a newbie to JavaScript ... --- index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index.js b/index.js index 705b28d..c5becad 100644 --- a/index.js +++ b/index.js @@ -62,6 +62,13 @@ async function run() { console.log('Charts dir content'); await exec.exec(`ls`, ['-I ".*"'], { cwd: `./${chartsDir}` }); for (const chartDirname of chartDirectories) { + console.log(`Resolving helm chart dependency in directory ${chartDirname}`); + await exec.exec( + `helm dependency update && helm dependency build`, + [], + { cwd: `./${chartsDir}/${chartDirname}` } + ); + console.log(`Packaging helm chart in directory ${chartDirname}`); await exec.exec( `helm package`, From e822b78ef3b9a8902755ed275d5722cdb7015d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=B5=E6=97=AD?= Date: Sat, 16 Nov 2019 00:54:01 +0800 Subject: [PATCH 3/4] fix: remove AND commands. no `&&` here? --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index c5becad..42199fd 100644 --- a/index.js +++ b/index.js @@ -64,7 +64,7 @@ async function run() { for (const chartDirname of chartDirectories) { console.log(`Resolving helm chart dependency in directory ${chartDirname}`); await exec.exec( - `helm dependency update && helm dependency build`, + `helm dependency update`, [], { cwd: `./${chartsDir}/${chartDirname}` } ); From aadd09db0752751c961532973aaac25b930ec9ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=B5=E6=97=AD?= Date: Sat, 16 Nov 2019 01:11:33 +0800 Subject: [PATCH 4/4] fix: try to exclude hidden folders. https://stackoverflow.com/questions/41472161/fs-readdir-ignore-directories https://stackoverflow.com/questions/18973655/how-to-ingnore-hidden-files-in-fs-readdir-result --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 42199fd..2c7c822 100644 --- a/index.js +++ b/index.js @@ -12,6 +12,7 @@ const getDirectories = fileName => withFileTypes: true, }) .filter(dirent => dirent.isDirectory()) + .filter(dirent => !(/(^|\/)\.[^\/\.]/g).test(dirent)) .map(dirent => dirent.name); async function run() {