@amir-cli/cli-init
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -6,5 +6,7 @@ import fs from 'fs'; | ||
const {file, object} = options | ||
if ((!object && !file) || (object && file)) { | ||
console.log(chalk.red('You need to pass either an object or file path')); | ||
} | ||
if (object) { | ||
@@ -11,0 +13,0 @@ const newObj = object.replace(/'/g, '"'); |
{ | ||
"name": "@amir-cli/cli-init", | ||
"type": "module", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "init plugin for cli", | ||
@@ -6,0 +6,0 @@ "main": "Init.js", |
# cli-init | ||
Init plugin for cli | ||
This is the GET plugin for [CLI project](https://github.com/Amir-61/cli). | ||
- **NPM:** [@amir-cli/cli-init](https://www.npmjs.com/package/@amir-cli/cli-init), **GITHUB:** [cli-init](https://github.com/Amir-61/cli-init) | ||
![image](https://user-images.githubusercontent.com/10672146/168502088-21eec0b6-5acc-47b2-a76e-2e898266a0ed.png) | ||
# Usages: | ||
- #### `INIT --object={myStringifiedObjectHere}` : | ||
will reset the datastore with provided object. For example `INIT --object="{'name':'foo'}"` will set/initialize the datasource with {'name':'foo'} | ||
- #### `INIT --file=sourceFilePath` : | ||
will reset the datastore the JSON file you provide. For example: `INIT --file="test.json"` | ||
# Connector structore: | ||
- `test` Folder: Each usage is unit tested using mocha | ||
- `init.js` file: It's like Data Access Object (DAO) of the connector where it exposes the newly implemented commands | ||
- `initHandlers.js` file: It's the handler for each exposed usages | ||
# Unit tests: | ||
- This connector comes with it's own unit tests written in [mocha](https://mochajs.org/), you can run unit tests for each module sperataly using `npm test` command. |
@@ -11,3 +11,3 @@ import assert from 'assert' | ||
'test': { | ||
'sampleFileToImport.json': "\"{'test': 'test3'}\"", | ||
'sampleFileToImport.json': "\"{'name': 'foo'}\"", | ||
} | ||
@@ -18,5 +18,5 @@ }); | ||
const file = `${process.cwd()}/data.json` | ||
await init({"object": "{'foo':'bar2'}"}) | ||
await init({"object": "{'foo':'bar'}"}) | ||
const result = readFileSync(file, 'utf8'); | ||
assert.deepStrictEqual(JSON.parse(result), { foo: 'bar2' }); | ||
assert.deepStrictEqual(JSON.parse(result), { foo: 'bar' }); | ||
@@ -29,3 +29,3 @@ }); | ||
const result = readFileSync(mockupFile, 'utf8'); | ||
assert.notDeepEqual(JSON.parse(result), { test: 'test3' }); | ||
assert.notDeepEqual(JSON.parse(result), { name: 'foo' }); | ||
}); | ||
@@ -32,0 +32,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4183
22