Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Toolchain
sgc
Commits
29115188
Commit
29115188
authored
Aug 29, 2018
by
Philipp Nowinski
Browse files
[FEATURE] migrate open task to new structure
parent
565f305d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
27 deletions
+37
-27
__old/modules/open.js
__old/modules/open.js
+0
-27
core/settings.js
core/settings.js
+1
-0
core/tasks/open.js
core/tasks/open.js
+36
-0
No files found.
__old/modules/open.js
deleted
100644 → 0
View file @
565f305d
'
use strict
'
;
const
open
=
require
(
'
opn
'
);
const
yargs
=
require
(
'
yargs
'
).
argv
;
const
settings
=
require
(
'
../../gulp/settings
'
);
const
chalk
=
require
(
'
chalk
'
);
if
(
yargs
.
_
.
length
>
1
)
{
const
config
=
settings
.
getConfig
();
if
(
config
.
hasOwnProperty
(
'
open
'
))
{
let
sites
=
yargs
.
_
[
1
];
if
(
config
.
open
.
hasOwnProperty
(
sites
))
{
let
index
=
0
;
config
.
open
[
sites
].
forEach
(
site
=>
{
setTimeout
(()
=>
{
open
(
site
);
},
100
*
index
++
);
});
}
else
{
console
.
log
(
chalk
.
red
(
`The desired entry
${
sites
}
could not be found in your .sgc-config.json!`
));
}
}
else
{
console
.
log
(
chalk
.
red
(
'
You have currently no sites configured (set the "open" property inside your .sgc-config.json)!
'
));
}
}
else
{
console
.
log
(
chalk
.
red
(
'
Please specify which site you want to open!
'
));
}
core/settings.js
View file @
29115188
...
...
@@ -24,6 +24,7 @@ class Settings {
watch
:
()
=>
{
return
require
(
'
./tasks/watch
'
)},
server
:
()
=>
{
return
require
(
'
./tasks/server
'
)},
images
:
()
=>
{
return
require
(
'
./tasks/images
'
)},
open
:
()
=>
{
return
require
(
'
./tasks/open
'
)},
default
:
()
=>
{
return
require
(
'
./tasks/default
'
)}
};
}
...
...
core/tasks/open.js
0 → 100644
View file @
29115188
const
Task
=
require
(
'
../task
'
);
const
open
=
require
(
'
opn
'
);
const
yargs
=
require
(
'
yargs
'
).
argv
;
const
chalk
=
require
(
'
chalk
'
);
/**
* Opens a defined URL in the default browser
*/
module
.
exports
=
class
Open
extends
Task
{
/**
* Runner function
*/
run
()
{
if
(
yargs
.
_
.
length
>
1
)
{
if
(
this
.
_config
.
hasOwnProperty
(
'
open
'
))
{
let
sites
=
yargs
.
_
[
1
];
if
(
this
.
_config
.
open
.
hasOwnProperty
(
sites
))
{
let
index
=
0
;
this
.
_config
.
open
[
sites
].
forEach
(
site
=>
{
setTimeout
(()
=>
{
open
(
site
);
},
100
*
index
++
);
});
}
else
{
this
.
_logger
.
error
(
`The desired entry
${
chalk
.
bold
(
sites
)}
could not be found in your .sgc-config.json!`
);
}
}
else
{
this
.
_logger
.
error
(
'
You have currently no sites configured (set the "open" property inside your .sgc-config.json)!
'
);
}
}
else
{
this
.
_logger
.
error
(
'
Please specify which site you want to open!
'
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment