Completed
Push — replace-version ( 38267b )
by Doğa
02:52
created

module.exports   A

Complexity

Conditions 2
Paths 7

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 2
c 2
b 0
f 1
nc 7
nop 1
dl 0
loc 16
rs 9.4285
1
const gulp = require('gulp')
2
const gutil = require('gulp-util')
3
const pjson = require('../../package.json')
4
const replace = require('replace-in-file')
5
6
module.exports = function (config) {
7
  gulp.task('replaceVersion', function (cb) {
8
    try {
9
      // read current version from package.json
10
      config.replaceVersion.php.to = pjson.version
11
      gutil.log(`Replacing ${config.replaceVersion.php.from} with ${config.replaceVersion.php.to} in all PHP files.`)
12
      replace.sync(config.replaceVersion.php)
13
14
      // replace WordPress theme version in style.css
15
      gutil.log('Updating WordPress theme version.')
16
      config.replaceVersion.wordpress.to += pjson.version
17
      replace.sync(config.replaceVersion.wordpress)
18
    } catch (error) {
19
      gutil.error('Error occurred:', error)
20
    }
21
    cb()
22
  })
23
}
24