fix(core): update
This commit is contained in:
@ -1 +1 @@
|
||||
export * from './smartscaf';
|
||||
export * from './smartscaf';
|
||||
|
@ -1,7 +1,7 @@
|
||||
export interface ISmartscafFile {
|
||||
defaults: {[key:string]: string};
|
||||
defaults: { [key: string]: string };
|
||||
dependencies: {
|
||||
merge: string[];
|
||||
};
|
||||
runafter: string[];
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import * as plugins from './smartscaf.plugins';
|
||||
import * as interfaces from './interfaces';
|
||||
import * as helpers from './smartscaf.helpers';
|
||||
|
||||
// interfaces
|
||||
import { Smartfile } from '@pushrocks/smartfile';
|
||||
@ -70,7 +69,7 @@ export class ScafTemplate {
|
||||
if (smartscafSmartfile) {
|
||||
smartscafFile = {
|
||||
...smartscafFile,
|
||||
...await plugins.smartyaml.yamlStringToObject(smartscafSmartfile.contentBuffer.toString())
|
||||
...(await plugins.smartyaml.yamlStringToObject(smartscafSmartfile.contentBuffer.toString()))
|
||||
};
|
||||
}
|
||||
this.smartscafFile = smartscafFile;
|
||||
@ -117,7 +116,7 @@ export class ScafTemplate {
|
||||
}
|
||||
const answerBucket = await localSmartInteract.runQueue();
|
||||
await answerBucket.answerMap.forEach(async answer => {
|
||||
await helpers.deepAddToObject(this.suppliedVariables, answer.name, answer.value);
|
||||
await plugins.smartparam.smartAdd(this.suppliedVariables, answer.name, answer.value);
|
||||
});
|
||||
}
|
||||
|
||||
@ -248,7 +247,7 @@ export class ScafTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
private async runScripts () {
|
||||
private async runScripts() {
|
||||
if (!this.destinationPath) {
|
||||
throw new Error('cannot run scripts without an destinationdir');
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
import * as plugins from './smartscaf.plugins';
|
||||
|
||||
/**
|
||||
* adds a variable in string dot notation to an already more or less expanded object
|
||||
*/
|
||||
export let deepAddToObject = async (objectArg, varStringArg: string, valueArg: string) => {
|
||||
let varNamesArray = varStringArg.split('.');
|
||||
let referencePointer = objectArg;
|
||||
for (let i = 0; i !== varNamesArray.length; i++) {
|
||||
let varName = varNamesArray[i];
|
||||
|
||||
// is there a next variable ?
|
||||
let varNameNext: string = (() => {
|
||||
if (varNamesArray[i + 1]) {
|
||||
return varNamesArray[i + 1];
|
||||
}
|
||||
return null;
|
||||
})();
|
||||
|
||||
// build the tree in suppliedVariables
|
||||
if (!referencePointer[varName] && !varNameNext) {
|
||||
referencePointer[varName] = valueArg;
|
||||
referencePointer = null;
|
||||
} else if (!referencePointer[varName] && varNameNext) {
|
||||
referencePointer[varName] = {};
|
||||
referencePointer = referencePointer[varName];
|
||||
} else if (referencePointer[varName] && varNameNext) {
|
||||
referencePointer = referencePointer[varName];
|
||||
} else {
|
||||
throw new Error('Something is strange!');
|
||||
}
|
||||
}
|
||||
};
|
@ -4,8 +4,20 @@ import * as smartfile from '@pushrocks/smartfile';
|
||||
import * as smartfm from '@pushrocks/smartfm';
|
||||
import * as smarthbs from '@pushrocks/smarthbs';
|
||||
import * as smartinteract from '@pushrocks/smartinteract';
|
||||
import * as smartq from '@pushrocks/smartpromise';
|
||||
import * as smartparam from '@pushrocks/smartparam';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartyaml from '@pushrocks/smartyaml';
|
||||
import * as smartshell from '@pushrocks/smartshell';
|
||||
|
||||
export { path, lik, smartfile, smartfm, smarthbs, smartinteract, smartq, smartyaml, smartshell };
|
||||
export {
|
||||
path,
|
||||
lik,
|
||||
smartfile,
|
||||
smartfm,
|
||||
smarthbs,
|
||||
smartinteract,
|
||||
smartparam,
|
||||
smartpromise,
|
||||
smartyaml,
|
||||
smartshell
|
||||
};
|
||||
|
Reference in New Issue
Block a user