remove.js (lodash-4.0.0) | : | remove.js (lodash-4.17.21) | ||
---|---|---|---|---|
#!/usr/bin/env node | #!/usr/bin/env node | |||
'use strict'; | 'use strict'; | |||
var fs = require('fs'), | var _ = require('../lodash'), | |||
fs = require('fs'), | ||||
path = require('path'); | path = require('path'); | |||
var args = (args = process.argv) | var args = (args = process.argv) | |||
.slice((args[0] === process.execPath || args[0] === 'node') ? 2 : 0); | .slice((args[0] === process.execPath || args[0] === 'node') ? 2 : 0); | |||
var filePath = path.resolve(args[1]), | var filePath = path.resolve(args[1]), | |||
reLine = /.*/gm, | reLine = /.*/gm; | |||
slice = Array.prototype.slice; | ||||
var pattern = (function() { | var pattern = (function() { | |||
var result = args[0], | var result = args[0], | |||
delimiter = result.charAt(0), | delimiter = result.charAt(0), | |||
lastIndex = result.lastIndexOf(delimiter); | lastIndex = result.lastIndexOf(delimiter); | |||
return RegExp(result.slice(1, lastIndex), result.slice(lastIndex + 1)); | return RegExp(result.slice(1, lastIndex), result.slice(lastIndex + 1)); | |||
}()); | }()); | |||
/*----------------------------------------------------------------------------*/ | /*----------------------------------------------------------------------------*/ | |||
fs.writeFileSync(filePath, fs.readFileSync(filePath, 'utf8').replace(pattern, fu nction(match) { | fs.writeFileSync(filePath, fs.readFileSync(filePath, 'utf8').replace(pattern, fu nction(match) { | |||
var snippet = slice.call(arguments, -3, -1)[0]; | var snippet = _.slice(arguments, -3, -2)[0]; | |||
return match.replace(snippet, snippet.replace(reLine, '')); | return match.replace(snippet, snippet.replace(reLine, '')); | |||
})); | })); | |||
End of changes. 3 change blocks. | ||||
4 lines changed or deleted | 4 lines changed or added |