Skip to content

Commit

Permalink
basic working model
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayuresh Waykole committed Jun 21, 2016
1 parent e58d859 commit 5433f09
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ A simple script that will remove logs in all js files in the directory. + a gith
## Usage
If you want the source to be rewritten
```
$ jscodeshift -t nologs.js test.js -p
$ jscodeshift -t transform.js test.js -p
```

If you would like to keep the source intact
```
$ jscodeshift -t nologs.js test.js -p -d
$ jscodeshift -t transform.js test.js -p -d
```

test.js is javascript file that you want to remove the logs from
35 changes: 34 additions & 1 deletion nologs.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env node

var fs = require('fs');
var program = require('commander');
var exec = require('child_process').exec;

var walk = function(dir) {
var results = []
Expand All @@ -16,4 +20,33 @@ var walk = function(dir) {
return results
}

// console.log(__dirname);
var parseJsFiles = function(dir){
console.log(typeof(dir));
// var fileList = walk(dir);
// fileList.forEach((file)=>{
// child_process.execSync(jscodeshift,['-t','transform.js','file','-p','-d'])
// })
}

var rewrite = function(fileList){

}

program
.command('dir [dir]')
.description('Give the directory to remove console.log')
.action(function(dir){
var fileList = walk(dir);
fileList.forEach((file)=>{
// execSync('jscodeshift',['-t','transform.js','file','-p','-d']);
exec(`jscodeshift -t transform.js ${file} -p -d`, function(err,stdout, stderr ){
console.log(stdout);
});
})
});

//
program
.version('0.0.1')
.option('-o, --ovr', 'Original files will be overwritten with output')
.parse(process.argv);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"homepage": "https://github.com/Mnw2212/nologs#readme",
"dependencies": {
"cli": "^0.11.2",
"commander": "^2.9.0",
"jscodeshift": "^0.3.22"
}
}

0 comments on commit 5433f09

Please sign in to comment.