ddf-query-validator
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -7,2 +7,3 @@ "use strict"; | ||
const get = require("lodash.get"); | ||
const path = require("path"); | ||
const helper_service_1 = require("./helper.service"); | ||
@@ -15,7 +16,9 @@ function getDatasetPath(basePath, queryParam) { | ||
function getDatapackagePath(datasetPath) { | ||
return datasetPath + '/datapackage.json'; | ||
return path.resolve(datasetPath, 'datapackage.json'); | ||
} | ||
function isDatasetPathAlreadyInBasePath(fileReader, basePath) { | ||
return new Promise((resolve) => { | ||
fileReader.readText(getDatapackagePath(basePath), (error) => resolve(!error)); | ||
fileReader.readText(getDatapackagePath(basePath), (error) => { | ||
return resolve(!error); | ||
}); | ||
}); | ||
@@ -35,3 +38,3 @@ } | ||
const { dataset: originDataset, branch: originBranch, commit: originCommit } = queryParam; | ||
const { dataset = DEFAULT_DATASET, branch = DEFAULT_BRANCH, commit = DEFAULT_COMMIT } = queryParam; | ||
let { dataset = DEFAULT_DATASET, branch = DEFAULT_BRANCH, commit = DEFAULT_COMMIT } = queryParam; | ||
const basePath = get(options, 'basePath', helper_service_1.DEFAULT_DATASET_DIR); | ||
@@ -52,3 +55,7 @@ const fileReader = get(options, 'fileReader'); | ||
try { | ||
if (yield isDatasetPathAlreadyInBasePath(fileReader, basePath)) { | ||
const isAlreadyDataset = yield isDatasetPathAlreadyInBasePath(fileReader, basePath); | ||
if (isAlreadyDataset) { | ||
dataset = basePath; | ||
branch = null; | ||
commit = null; | ||
datasetPath = basePath; | ||
@@ -55,0 +62,0 @@ datapackagePath = getDatapackagePath(basePath); |
{ | ||
"name": "ddf-query-validator", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "DDF query validator", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
import * as isNil from 'lodash.isnil'; | ||
import * as includes from 'lodash.includes'; | ||
import * as get from 'lodash.get'; | ||
import * as path from 'path'; | ||
import { | ||
@@ -22,3 +23,3 @@ DEFAULT_DATASET_BRANCH, | ||
function getDatapackagePath(datasetPath): string { | ||
return datasetPath + '/datapackage.json'; | ||
return path.resolve(datasetPath, 'datapackage.json'); | ||
} | ||
@@ -28,3 +29,5 @@ | ||
return new Promise((resolve) => { | ||
fileReader.readText(getDatapackagePath(basePath), (error) => resolve(!error)); | ||
fileReader.readText(getDatapackagePath(basePath), (error) => { | ||
return resolve(!error); | ||
}); | ||
}); | ||
@@ -55,3 +58,3 @@ } | ||
} = queryParam; | ||
const { | ||
let { | ||
dataset = DEFAULT_DATASET, | ||
@@ -82,3 +85,7 @@ branch = DEFAULT_BRANCH, | ||
try { | ||
if (await isDatasetPathAlreadyInBasePath(fileReader, basePath)) { | ||
const isAlreadyDataset = await isDatasetPathAlreadyInBasePath(fileReader, basePath); | ||
if (isAlreadyDataset) { | ||
dataset = basePath; | ||
branch = null; | ||
commit = null; | ||
datasetPath = basePath; | ||
@@ -85,0 +92,0 @@ datapackagePath = getDatapackagePath(basePath); |
Sorry, the diff of this file is not supported yet
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
124303
1460