[ADF-2759] Updated doc script to allow multiple config profiles (#3211)

This commit is contained in:
Andy Stark 2018-04-18 11:15:47 +01:00 committed by Eugenio Romano
parent 1b2bd6220e
commit 026da57cb8
2 changed files with 30 additions and 33 deletions

View File

@ -85,10 +85,9 @@ function loadToolModules() {
} }
function loadToolConfig(configFilePath) { function loadConfig() {
var config = JSON.parse(fs.readFileSync(configFilePath)); var configFilePath = path.resolve(__dirname, configFileName)
return JSON.parse(fs.readFileSync(configFilePath));
return config.enabledTools;
} }
@ -110,38 +109,33 @@ function getAllDocFilePaths(docFolder, files) {
program program
.usage("[options] <source>") .usage("[options] <source>")
.option("-p, --profile [profileName]", "Select named config profile", "index")
.parse(process.argv); .parse(process.argv);
var sourcePath;
if (program.args.length === 0) { if (program.args.length === 0) {
console.log("Error: source argument required"); sourcePath = path.resolve("..", "docs");
return 0; } else {
sourcePath = path.resolve(program.args[0]);
} }
var sourcePath = path.resolve(program.args[0]);
var sourceInfo = fs.statSync(sourcePath); var sourceInfo = fs.statSync(sourcePath);
/* var toolModules = loadToolModules();
var destPath;
var destInfo;
if (program.args.length >= 2) { var config = loadConfig();
destPath = path.resolve(program.args[1]);
destInfo = fs.statSync(sourcePath); var toolList;
if (config.profiles[program.profile]){
toolList = config.profiles[program.profile];
var toolListText = toolList.join(", ");
console.log(`Using '${program.profile}' profile: ${toolListText}`);
} else { } else {
destPath = sourcePath; console.log(`Aborting: unknown profile '${program.profile}`);
destInfo = sourceInfo;
}
if (sourceInfo.isDirectory() && !destInfo.isDirectory()) {
console.log("Error: The <dest> argument must be a directory");
return 0; return 0;
} }
*/
var toolModules = loadToolModules();
var toolList = loadToolConfig(path.resolve(__dirname, configFileName));
var files = []; var files = [];
@ -149,9 +143,6 @@ if (sourceInfo.isDirectory()) {
getAllDocFilePaths(sourcePath, files); getAllDocFilePaths(sourcePath, files);
} else if (sourceInfo.isFile()) { } else if (sourceInfo.isFile()) {
files = [ sourcePath ]; files = [ sourcePath ];
//files = [ path.basename(sourcePath) ];
//sourcePath = path.dirname(sourcePath);
//destPath = path.dirname(destPath);
} }
files = files.filter(filename => files = files.filter(filename =>

View File

@ -1,7 +1,13 @@
{ {
"enabledTools": [ "profiles": {
"index", "index": [
"versionIndex", "index",
"tutorialIndex" "versionIndex",
] "tutorialIndex"
],
"enhance": [
"tsInfo",
"toc"
]
}
} }