Skip to content

Commit 6bac4c6

Browse files
init file added
1 parent 8a13398 commit 6bac4c6

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

commands/init.js

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,40 @@ function create_file(file_path, content) {
1212
}
1313

1414
function create_ltconfig_file(args) {
15-
let config = require('./utils/default_config.js')
16-
let content = JSON.stringify(config, null, 3);
17-
if (args._.length == 1) {
18-
create_file(constants.LT_CONFIG_NAME, content)
15+
let cv=9.6
16+
if("cv" in args){
17+
cv=args["cv"]
18+
}else{
19+
1920
}
20-
else if (args._.length > 1) {
21+
let config =parseInt(cv)>=10?require('./utils/default_config_10.js'):require('./utils/default_config_9.js')
22+
config.run_settings.npm_dependencies.cypress=cv.toString()
23+
let content = JSON.stringify(config, null, 3);
24+
if ("config-file-name" in args && "config-file-name" !=""){
2125
//check if file or directory exists
22-
if (fs.existsSync(args._[1])) {
23-
let stats = fs.statSync(args._[1]);
26+
if (fs.existsSync(args["config-file-name"])) {
27+
let stats = fs.statSync(args["config-file-name"]);
2428
if (stats.isFile()) {
25-
make_file(args._[1], content)
29+
create_file(args["config-file-name"], content)
2630
}
2731
else {
28-
create_file(path.join(args._[1], constants.LT_CONFIG_NAME), content)
32+
create_file(path.join(args["config-file-name"], constants.LT_CONFIG_NAME), content)
2933
}
3034
}
3135
else {
32-
filename = path.basename(args._[1])
36+
filename = path.basename(args["config-file-name"])
3337
var re = new RegExp(".+\\..+");
3438
if (re.test(filename)) {
35-
fs.mkdirSync(path.dirname(args._[1]), { recursive: true });
36-
create_file(args._[1], content)
37-
}
38-
else {
39-
fs.mkdirSync(args._[1], { recursive: true });
40-
create_file(path.join(args._[1], constants.LT_CONFIG_NAME), content)
39+
fs.mkdirSync(path.dirname(args["config-file-name"]), { recursive: true });
40+
create_file(args["config-file-name"], content)
41+
}else {
42+
fs.mkdirSync(args["config-file-name"], { recursive: true });
43+
create_file(path.join(args["config-file-name"], constants.LT_CONFIG_NAME), content)
4144
}
4245
}
46+
}else{
47+
console.log("Picking the default config file name ",constants.LT_CONFIG_NAME)
48+
create_file(constants.LT_CONFIG_NAME, content)
4349
}
4450
};
4551

@@ -59,13 +65,18 @@ function create_custom_support_file(args){
5965
console.log("Error while copying custom support file", err);
6066
}
6167
else {
62-
console.log("Successfully saved custom support file at - ", pathToNewDestination);
68+
console.log("Saved at ", pathToNewDestination);
6369
}
6470
});
6571
}
6672

6773
module.exports = function (args) {
6874
create_ltconfig_file(args);
6975
create_base_reporter_config_file(args);
70-
create_custom_support_file(args);
76+
if ("cv" in args){
77+
console.log("cv is ",args["cv"])
78+
if (parseInt(args["cv"])>=10){
79+
create_custom_support_file(args);
80+
}
81+
}
7182
};

0 commit comments

Comments
 (0)