Skip to content

Commit

Permalink
Update gulpfile and README for gulp 4.x
Browse files Browse the repository at this point in the history
Fixes for these gulp errors:
  - AssertionError [ERR_ASSERTION]: Task function must be specified
  - AssertionError [ERR_ASSERTION]: Task never defined: readme
  -   gulpjs/gulp#802
  - The following tasks did not complete: check-priv
    - Did you forget to signal async completion?
  - Error: watching conf.priv.js,completions.js,conf.js,actions.js,help.js,keys.js,util.js,gulpfile.js: watch task has to be a function (optionally generated by using gulp.parallel or gulp.series)

Update README to use local ./node_modules/.bin/gulp instead of global
gulp.
  • Loading branch information
jeebak committed Dec 28, 2018
1 parent 18badf8 commit f237eb1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 26 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ Building `surfingkeys-conf` requires a few dependencies to be installed:

4. __Gulp Build/Install__
```shell
$ gulp install # OR "gulp build" to build to ./build/.surfingkeys without installing
$ ./node_modules/.bin/gulp install # OR "./node_modules/.bin/gulp build" to build to ./build/.surfingkeys without installing
```

This will build the final configuration file and place it at `~/.surfingkeys`.
Expand All @@ -260,14 +260,14 @@ Building `surfingkeys-conf` requires a few dependencies to be installed:
- __Linux__: `file:///home/{USERNAME}/.surfingkeys` (replace `{USERNAME}` with your username)
- __macOS__: `file:///Users/{USERNAME}/.surfingkeys` (replace `{USERNAME}` with your username)
- __Windows__: `file://%Homedrive%%Homepath%/.surfingkeys` (This is a guess, please correct me if I'm wrong)
- __IV.__ Hack Away! If you ever make a change to any of your configuration files in the future, simply run `gulp install` again and your new configuration will automatically be loaded by SurfingKeys.
- __IV.__ Hack Away! If you ever make a change to any of your configuration files in the future, simply run `./node_modules/.bin/gulp install` again and your new configuration will automatically be loaded by SurfingKeys.

</details>

<details>
<summary><strong>Option B</strong>: Manually copy/paste into the SurfingKeys configuration form</summary>

- __I.__ Copy the contents of `./build/.surfingkeys` (or `$HOME/.surfingkeys` if you ran `gulp install`)
- __I.__ Copy the contents of `./build/.surfingkeys` (or `$HOME/.surfingkeys` if you ran `./node_modules/.bin/gulp install`)

- __II.__ Open the SurfingKeys [configuration page](chrome-extension://mffcegbjcdejldmihkogmcnkgbbhioid/pages/options.html)

Expand Down
6 changes: 3 additions & 3 deletions README.tmpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Building `surfingkeys-conf` requires a few dependencies to be installed:

4. __Gulp Build/Install__
```shell
$ gulp install # OR "gulp build" to build to ./build/.surfingkeys without installing
$ ./node_modules/.bin/gulp install # OR "./node_modules/.bin/gulp build" to build to ./build/.surfingkeys without installing
```

This will build the final configuration file and place it at `~/.surfingkeys`.
Expand All @@ -115,14 +115,14 @@ Building `surfingkeys-conf` requires a few dependencies to be installed:
- __Linux__: `file:///home/{USERNAME}/.surfingkeys` (replace `{USERNAME}` with your username)
- __macOS__: `file:///Users/{USERNAME}/.surfingkeys` (replace `{USERNAME}` with your username)
- __Windows__: `file://%Homedrive%%Homepath%/.surfingkeys` (This is a guess, please correct me if I'm wrong)
- __IV.__ Hack Away! If you ever make a change to any of your configuration files in the future, simply run `gulp install` again and your new configuration will automatically be loaded by SurfingKeys.
- __IV.__ Hack Away! If you ever make a change to any of your configuration files in the future, simply run `./node_modules/.bin/gulp install` again and your new configuration will automatically be loaded by SurfingKeys.

</details>

<details>
<summary><strong>Option B</strong>: Manually copy/paste into the SurfingKeys configuration form</summary>

- __I.__ Copy the contents of `./build/.surfingkeys` (or `$HOME/.surfingkeys` if you ran `gulp install`)
- __I.__ Copy the contents of `./build/.surfingkeys` (or `$HOME/.surfingkeys` if you ran `./node_modules/.bin/gulp install`)

- __II.__ Open the SurfingKeys [configuration page](chrome-extension://mffcegbjcdejldmihkogmcnkgbbhioid/pages/options.html)

Expand Down
46 changes: 26 additions & 20 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ gulp.task("gulp-autoreload", () => {
let p
const spawnChildren = function spawnChildren() {
if (p) p.kill()
p = spawn("gulp", ["lint-gulpfile", "install", "watch-nogulpfile"], { stdio: "inherit" })
p = spawn("./node_modules/.bin/gulp", ["lint-gulpfile", "install", "watch-nogulpfile"], { stdio: "inherit" })
}
gulp.watch("gulpfile.js", spawnChildren)
spawnChildren()
Expand All @@ -57,32 +57,16 @@ gulp.task("lint", () =>
.pipe(eslint())
.pipe(eslint.format()))

gulp.task("check-priv", () => {
gulp.task("check-priv", (done) => {
try {
fs.statSync("./conf.priv.js")
} catch (e) {
// eslint-disable-next-line no-console
console.log("Creating ./conf.priv.js based on ./conf.priv.example.js")
fs.copyFileSync("./conf.priv.example.js", "./conf.priv.js", fs.constants.COPYFILE_EXCL)
}
})

gulp.task("build", ["check-priv", "clean", "lint", "readme"], () => gulp.src(paths.entry, { read: false })
.pipe(parcel())
.pipe(rename(".surfingkeys"))
.pipe(gulp.dest("build")))

gulp.task("install", ["build"], () => gulp.src("build/.surfingkeys")
.pipe(gulp.dest(os.homedir())))

gulp.task("watch", () => {
gulp.watch([].concat(paths.scripts, paths.gulpfile), ["readme", "install"])
gulp.watch(paths.readme, ["readme"])
})

gulp.task("watch-nogulpfile", () => {
gulp.watch([].concat(paths.scripts), ["readme", "install"])
gulp.watch(paths.readme, ["readme"])
done()
})

gulp.task("readme", () => {
Expand Down Expand Up @@ -154,4 +138,26 @@ gulp.task("readme", () => {
.pipe(gulp.dest("."))
})

gulp.task("default", ["build"])
gulp.task("build", gulp.series("check-priv", "clean", "lint", "readme"), (done) => {
gulp.src(paths.entry, { read: false })
.pipe(parcel())
.pipe(rename(".surfingkeys"))
.pipe(gulp.dest("build"))

done()
})

gulp.task("install", gulp.series("build"), () => gulp.src("build/.surfingkeys")
.pipe(gulp.dest(os.homedir())))

gulp.task("watch", () => {
gulp.watch([].concat(paths.scripts, paths.gulpfile), gulp.series("readme", "install"))
gulp.watch(paths.readme, gulp.series("readme"))
})

gulp.task("watch-nogulpfile", () => {
gulp.watch([].concat(paths.scripts), gulp.series("readme", "install"))
gulp.watch(paths.readme, gulp.series("readme"))
})

gulp.task("default", gulp.series("build"))

0 comments on commit f237eb1

Please sign in to comment.