From 7b28e8f4200f45b94b068318e5503c90cde4fcc4 Mon Sep 17 00:00:00 2001 From: Sergey Shpak Date: Tue, 30 Mar 2021 01:33:17 +0200 Subject: [PATCH 1/2] Add Docker support --- Dockerfile | 5 +++++ index.js | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a316599 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM node:alpine + +COPY . /nagibabel.js +RUN cd /nagibabel.js && npm install --ignore-scripts +ENTRYPOINT ["/nagibabel.js/bin/nagibabel.js", "--path"] diff --git a/index.js b/index.js index 1b8c38f..5821ab3 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ +const path = require('path') const rimraf = require('rimraf') const minimist = require('minimist') @@ -5,7 +6,15 @@ const projectDir = process.cwd() const args = minimist(process.argv.slice(2)) const pathToDelete = args.path || projectDir +const successMsg = 'All bad code is cleared. 😎' -rimraf(pathToDelete, () => { - console.log('All bad code is cleared. 😎') +rimraf(pathToDelete, (er) => { + if (er) { + // "best-effort" fallback + rimraf(path.join(pathToDelete, '*'), () => { + console.log(successMsg) + }) + return + } + console.log(successMsg) }) From 8e9ed2dc233688965678f5ccf0a1e1fb40f5ec8c Mon Sep 17 00:00:00 2001 From: Sergey Shpak Date: Tue, 30 Mar 2021 01:36:02 +0200 Subject: [PATCH 2/2] Document usage with Docker --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index f5c4f47..4ea426d 100644 --- a/README.md +++ b/README.md @@ -16,3 +16,21 @@ git clone https://github.com/fual/nagibabel.js cd nagibabel.js node index.js ``` + +### Using Docker + +You can also run nagigbabel.js with Docker: + +```sh +docker build -t nagibabel . +docker run --rm -v /my/awesome/project:/my/awesome/project nagibabel /my/awesome/project +``` + +Due to the technical limitations of Docker, only the directory contents are processed, not the directory itself. + +You can bypass it by mounting the directory that contains your target folder: + +```sh +docker build -t nagibabel . +docker run --rm -v /my/awesome/:/my/awesome/ nagibabel /my/awesome/project +```