@onkarruikar/test-package
Advanced tools
Comparing version 1.0.2 to 1.0.3
28
index.js
@@ -0,1 +1,3 @@ | ||
// test package | ||
const path = require('path'); | ||
@@ -6,11 +8,23 @@ const fs = require('fs'); | ||
function init(rootDir = process.cwd()) { | ||
function init(rootDir = null) { | ||
console.log(`test-package: process.cwd(): ${process.cwd()}`); | ||
console.log(`test-package: path.resolve('./'): ${path.resolve('./')}`); | ||
if(!rootDir){ | ||
//rootDir = path.resolve('./'); | ||
// OR | ||
rootDir = process.cwd(); | ||
} | ||
//const configPath = path.resolve('./', CONFIG_NAME); | ||
// OR | ||
const configPath = path.join(rootDir, CONFIG_NAME); | ||
if (fs.existsSync(configPath)) { | ||
console.log(`Reading config from: ${configPath}`); | ||
console.log(`test-package: Reading config from: ${configPath}`); | ||
try { | ||
//const data = fs.readFileSync(configPath, 'utf8'); | ||
//const config = JSON.parse(data); | ||
// OR | ||
const config = require(configPath); | ||
@@ -23,11 +37,15 @@ console.log(config); | ||
console.log(`Couldn't find config file ${configPath}. Using default.`) | ||
console.log(`test-package: Couldn't find config file ${configPath}. Using default.`) | ||
} | ||
console.log('\n') | ||
} | ||
//init() | ||
const features.init = init; | ||
const features = { | ||
init:init, | ||
message: `Hello from test-package! 👋` | ||
} | ||
module.exports = features; |
{ | ||
"name": "@onkarruikar/test-package", | ||
"version": "1.0.2" , | ||
"version": "1.0.3" , | ||
"main": "index.js" | ||
} |
1215
37