@ghii/yaml-loader
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -1,21 +0,1 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -30,16 +10,12 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const yaml_loader_1 = __importDefault(require("../yaml-loader")); | ||
const fs = __importStar(require("fs")); | ||
const path_1 = __importDefault(require("path")); | ||
import yamlLoader from '../yaml-loader'; | ||
import * as fs from 'fs'; | ||
import path from 'path'; | ||
describe('Ghii Yaml Loader', () => { | ||
it('export a function', () => { | ||
expect(typeof yaml_loader_1.default).toBe('function'); | ||
expect(typeof yamlLoader).toBe('function'); | ||
}); | ||
describe('to create a loader', () => { | ||
it('create a file loader from yaml file - check if is a function', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const yamlFileLoader = yaml_loader_1.default({ throwOnError: false }, __dirname, 'test.yaml'); | ||
const yamlFileLoader = yamlLoader({ throwOnError: false }, __dirname, 'test.yaml'); | ||
yield expect(typeof yamlFileLoader).toBe('function'); | ||
@@ -49,3 +25,3 @@ })); | ||
expect(() => { | ||
yaml_loader_1.default({ throwOnError: true }, __dirname, 'test_not_exist.yaml'); | ||
yamlLoader({ throwOnError: true }, __dirname, 'test_not_exist.yaml'); | ||
}).toThrow(); | ||
@@ -55,13 +31,13 @@ })); | ||
expect(() => { | ||
yaml_loader_1.default({ throwOnError: false }, __dirname, 'test_not_exist.yaml'); | ||
yamlLoader({ throwOnError: false }, __dirname, 'test_not_exist.yaml'); | ||
}).not.toThrow(); | ||
})); | ||
it('attempt to read a folder throw Error', () => __awaiter(void 0, void 0, void 0, function* () { | ||
expect(yaml_loader_1.default({ throwOnError: true }, __dirname)).rejects.toBeInstanceOf(Error); | ||
expect(yamlLoader({ throwOnError: true }, __dirname)).rejects.toBeInstanceOf(Error); | ||
})); | ||
it('attempt to read a folder with no throw Error', () => __awaiter(void 0, void 0, void 0, function* () { | ||
expect(yield yaml_loader_1.default({ throwOnError: false }, __dirname)()).toStrictEqual({}); | ||
expect(yield yamlLoader({ throwOnError: false }, __dirname)()).toStrictEqual({}); | ||
})); | ||
it('create a file loader from yaml file', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const content = yield yaml_loader_1.default({ throwOnError: true }, __dirname, 'test.yaml')(); | ||
const content = yield yamlLoader({ throwOnError: true }, __dirname, 'test.yaml')(); | ||
yield expect(content).toStrictEqual({ | ||
@@ -74,8 +50,8 @@ foo: { | ||
it('create a file loader from yaml file removed after init', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = path_1.default.join(__dirname, '../__test__/test.yaml'); | ||
const copy = path_1.default.join(__dirname, '../__test__/test-temp-copy.yaml'); | ||
const src = path.join(__dirname, '../__test__/test.yaml'); | ||
const copy = path.join(__dirname, '../__test__/test-temp-copy.yaml'); | ||
if (fs.existsSync(copy)) | ||
fs.rmSync(copy); | ||
fs.copyFileSync(src, copy); | ||
const fileLoader = yield yaml_loader_1.default({ throwOnError: true }, __dirname, 'test-temp-copy.yaml'); | ||
const fileLoader = yield yamlLoader({ throwOnError: true }, __dirname, 'test-temp-copy.yaml'); | ||
fs.rmSync(copy); | ||
@@ -85,8 +61,8 @@ yield expect(fileLoader()).rejects.toBeInstanceOf(Error); | ||
it('create a file loader from yaml file removed after init with no throw', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = path_1.default.join(__dirname, '../__test__/test.yaml'); | ||
const copy = path_1.default.join(__dirname, '../__test__/test-temp-copy.yaml'); | ||
const src = path.join(__dirname, '../__test__/test.yaml'); | ||
const copy = path.join(__dirname, '../__test__/test-temp-copy.yaml'); | ||
if (fs.existsSync(copy)) | ||
fs.rmSync(copy); | ||
fs.copyFileSync(src, copy); | ||
const fileLoader = yield yaml_loader_1.default({ throwOnError: false }, __dirname, 'test-temp-copy.yaml'); | ||
const fileLoader = yield yamlLoader({ throwOnError: false }, __dirname, 'test-temp-copy.yaml'); | ||
fs.rmSync(copy); | ||
@@ -93,0 +69,0 @@ yield expect(fileLoader()).resolves.toStrictEqual({}); |
@@ -1,21 +0,1 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -30,14 +10,10 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const js_yaml_1 = __importDefault(require("js-yaml")); | ||
const fs = __importStar(require("fs")); | ||
const util_1 = require("util"); | ||
const path_1 = __importDefault(require("path")); | ||
const stat = util_1.promisify(fs.stat); | ||
const readFile = util_1.promisify(fs.readFile); | ||
function yamlLoader({ throwOnError, logger = (err, message) => console.log(message, err), }, ...filePathToken) { | ||
const sourcePath = path_1.default.join(...filePathToken); | ||
import yaml from 'js-yaml'; | ||
import * as fs from 'fs'; | ||
import { promisify } from 'util'; | ||
import path from 'path'; | ||
const stat = promisify(fs.stat); | ||
const readFile = promisify(fs.readFile); | ||
export default function yamlLoader({ throwOnError, logger = (err, message) => console.log(message, err), }, ...filePathToken) { | ||
const sourcePath = path.join(...filePathToken); | ||
if (!fs.existsSync(sourcePath)) { | ||
@@ -54,3 +30,3 @@ logger({ msg: 'not exist' }, `${sourcePath} 404`); | ||
const yamlContent = yield readFile(sourcePath, { encoding: 'utf8' }); | ||
return js_yaml_1.default.safeLoad(yamlContent); | ||
return yaml.load(yamlContent); | ||
} | ||
@@ -74,3 +50,3 @@ const msg = `Source ${sourcePath} is not a file`; | ||
} | ||
exports.default = yamlLoader; | ||
export { yamlLoader }; | ||
//# sourceMappingURL=yaml-loader.js.map |
@@ -6,2 +6,3 @@ import { Loader } from '@ghii/ghii'; | ||
}, ...filePathToken: string[]): Loader; | ||
export { yamlLoader }; | ||
//# sourceMappingURL=yaml-loader.d.ts.map |
{ | ||
"name": "@ghii/yaml-loader", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "A Funny yaml loader for ghii configuration manager ", | ||
@@ -36,3 +36,3 @@ "maintainers": [ | ||
"prebuild": "rimraf dist", | ||
"build": "tsc --module commonjs && typedoc --out docs --target es6 --theme minimal --mode file src", | ||
"build": "tsc", | ||
"start": "rollup -c rollup.config.ts -w", | ||
@@ -71,25 +71,25 @@ "test": "jest --coverage", | ||
"devDependencies": { | ||
"@ghii/ghii": "0.0.1", | ||
"@types/jest": "^26.0.15", | ||
"@types/js-yaml": "^3.12.5", | ||
"@types/node": "^14.14.6", | ||
"@typescript-eslint/eslint-plugin": "^4.6.1", | ||
"@typescript-eslint/parser": "^4.6.1", | ||
"coveralls": "^3.1.0", | ||
"cross-env": "^7.0.2", | ||
"eslint": "^7.13.0", | ||
"eslint-config-prettier": "^6.15.0", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"jest": "^26.6.3", | ||
"jest-config": "^26.6.3", | ||
"prettier": "^2.1.2", | ||
"@ghii/ghii": "1.0.0", | ||
"@types/jest": "^29.2.3", | ||
"@types/js-yaml": "^4.0.5", | ||
"@types/node": "^18.11.9", | ||
"@typescript-eslint/eslint-plugin": "^5.45.0", | ||
"@typescript-eslint/parser": "^5.45.0", | ||
"coveralls": "^3.1.1", | ||
"cross-env": "^7.0.3", | ||
"eslint": "^8.28.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"jest": "^29.3.1", | ||
"jest-config": "^29.3.1", | ||
"prettier": "^2.8.0", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^26.4.3", | ||
"ts-node": "^9.0.0", | ||
"typedoc": "^0.19.2", | ||
"typescript": "^4.0.5" | ||
"ts-jest": "^29.0.3", | ||
"ts-node": "^10.9.1", | ||
"typedoc": "^0.23.21", | ||
"typescript": "^4.9.3" | ||
}, | ||
"dependencies": { | ||
"js-yaml": "^3.14.0" | ||
"js-yaml": "^4.1.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
14671
122
+ Addedargparse@2.0.1(transitive)
+ Addedjs-yaml@4.1.0(transitive)
- Removedargparse@1.0.10(transitive)
- Removedesprima@4.0.1(transitive)
- Removedjs-yaml@3.14.1(transitive)
- Removedsprintf-js@1.0.3(transitive)
Updatedjs-yaml@^4.1.0