-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For #4 scaffold cms utility to upsert a single content item, all cont…
…ent items of a single content type or all content items of all content types, using a fuzzy search command line widget
- Loading branch information
1 parent
05f5cea
commit 9db84ca
Showing
3 changed files
with
438 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict' | ||
var inquirer = require('inquirer') | ||
var shell = require('shelljs') | ||
var fs = require('fs') | ||
var path = require('path') | ||
|
||
inquirer.registerPrompt('fuzzypath', require('inquirer-fuzzy-path')) | ||
|
||
var questions = [ | ||
{ | ||
type: 'fuzzypath', | ||
name: 'file', | ||
rootPath: '/home/durabledrupal/ddcmr/dev/cms/content', | ||
message: 'Choose single file, entire content type (folder) or all content (parent content folder) to upsert' | ||
} | ||
] | ||
|
||
inquirer.prompt(questions).then(answers => { | ||
console.log(JSON.stringify(answers, null, ' ')); | ||
var dirname = path.basename(path.dirname(answers.file)) | ||
var basename = path.basename(answers.file) | ||
var extname = path.extname(answers.file) | ||
console.log('basename', basename) | ||
console.log('extname', extname) | ||
fs.stat(answers.file, function(err, stats) { | ||
if (stats.isDirectory()) { | ||
console.log('directory') | ||
if (basename === 'content') { | ||
console.log('upsert all') | ||
} else { | ||
console.log('upsert all', basename) | ||
} | ||
} | ||
if (stats.isFile()) { | ||
console.log('file') | ||
console.log('upsert content item ', basename, ' for content type ', dirname) | ||
} | ||
console.log('stats', stats) | ||
}) | ||
}) |
Oops, something went wrong.