Created
December 6, 2016 01:12
-
-
Save BraunreutherA/af89e7483bd8d4150081fa0c553a4c8e to your computer and use it in GitHub Desktop.
Keystone.js custom fields
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
/** | |
* This little script copies the custom fields into the node modules directly into the keystone types. | |
* Afterwards it hooks into the keystone field types and registers the new model. | |
* | |
* ATTENTION if a model already exists it'll overwrite it. | |
* This way you can copy the fields and update them to your liking. | |
*/ | |
var _ = require('lodash'); | |
var shell = require('shelljs'); | |
var path = require('path'); | |
function customFields (keystone, fieldPath, nodeModulesPath, mapping) { | |
shell.cp('-R', `${fieldPath}/*`, path.join(nodeModulesPath, 'keystone', 'fields', 'types')); | |
_.assign(keystone.fieldTypes, mapping); | |
} | |
// customFields( | |
// keystone, | |
// path.join(__dirname, 'fields'), | |
// path.join(__dirname, 'node_modules'), | |
// { file: 'File' } | |
// ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment