Skip to content

Commit

Permalink
[init][s]: normalize dataset name property accoring to specs - refs d…
Browse files Browse the repository at this point in the history
  • Loading branch information
anuveyatsu committed Apr 24, 2018
1 parent 7a6e7a8 commit a36b72c
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class Init extends EventEmitter {
// Guess default name from cwd name:
const fullPath = path.resolve('', this.path_)
let datasetName = path.basename(fullPath)
.toLowerCase()
.trim()
.replace(/&/g, '-and-')
.replace(/[^a-z0-9-._]+/g, '-')
// Make unslugified version for title:
let datasetTitle = datasetName.replace(/-+/g, ' ')
datasetTitle = datasetTitle.charAt(0).toUpperCase() + datasetTitle.slice(1)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"cli-table": "^0.3.1",
"csv-parse": "^2.0.0",
"csv-stringify": "^2.0.0",
"data.js": "^0.11.3",
"data.js": "^0.11.4",
"events": "^1.1.1",
"form-data": "^2.3.1",
"inquirer": "4.0.2",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions test/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const {Init} = require('../lib/init')

const initializer = new Init({
interactive: false,
path_: 'test/fixtures/readdir-test/'
path_: 'test/fixtures/readdir test/'
})

test('createDataset', async t => {
Expand All @@ -25,7 +25,7 @@ test('createDataset', async t => {
format: "csv",
mediatype: "text/csv",
name: "sample1",
path: "test/fixtures/readdir-test/sample1.csv",
path: "test/fixtures/readdir test/sample1.csv",
pathType: "local",
schema: {
fields: [
Expand All @@ -52,15 +52,15 @@ test('createDataset', async t => {
encoding: "ISO-8859-9",
format: "",
name: "sample2",
path: "test/fixtures/readdir-test/dir/sample2",
path: "test/fixtures/readdir test/dir/sample2",
pathType: "local"
},
{
encoding: "UTF-8",
format: "json",
mediatype: "application/json",
name: "sample3",
path: "test/fixtures/readdir-test/dir/dir2/sample3.json",
path: "test/fixtures/readdir test/dir/dir2/sample3.json",
pathType: "local",
}
],
Expand Down

0 comments on commit a36b72c

Please sign in to comment.