made a mini app which you can select the demo you want from a list with an interactive prompt.
This commit is contained in:
29
demo/index.js
Normal file
29
demo/index.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
var prompt = require('prompt');
|
||||||
|
var shelljs = require('shelljs');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
console.log('What demo do you wish to run? (Enter a number)');
|
||||||
|
|
||||||
|
var schema = {
|
||||||
|
properties: {
|
||||||
|
number: {
|
||||||
|
pattern: /^[0-9]+$/,
|
||||||
|
message: 'Please enter a number.',
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
prompt.start();
|
||||||
|
|
||||||
|
prompt.get(schema, function (err, result) {
|
||||||
|
var demoNumber = result.number;
|
||||||
|
var filePath = `./demo/demo${demoNumber}.js`;
|
||||||
|
|
||||||
|
if (!fs.existsSync(filePath)) {
|
||||||
|
console.error(`demo${demoNumber} does not exist: ${filePath}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(`Running demo ${demoNumber}`);
|
||||||
|
shelljs.exec(`node ${filePath}`);
|
||||||
|
});
|
@ -9,8 +9,7 @@
|
|||||||
"prepublishOnly": "npm run build",
|
"prepublishOnly": "npm run build",
|
||||||
"lint": "tslint --project ./ts",
|
"lint": "tslint --project ./ts",
|
||||||
"build": "rimraf ./build && tsc -p ts",
|
"build": "rimraf ./build && tsc -p ts",
|
||||||
"demo": "npm run build && node ./demo/demo.js",
|
"demo": "npm run build && node ./demo"
|
||||||
"demo2": "npm run build && node ./demo/demo2.js"
|
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts",
|
"ts",
|
||||||
@ -49,7 +48,9 @@
|
|||||||
"@types/mocha": "^2.2.39",
|
"@types/mocha": "^2.2.39",
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
"mocha": "^3.2.0",
|
"mocha": "^3.2.0",
|
||||||
|
"prompt": "^1.0.0",
|
||||||
"rimraf": "^2.5.2",
|
"rimraf": "^2.5.2",
|
||||||
|
"shelljs": "^0.7.7",
|
||||||
"tslint": "^4.5.1",
|
"tslint": "^4.5.1",
|
||||||
"typescript": "^2.2.1"
|
"typescript": "^2.2.1"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user