Skip to content

Commit

Permalink
6.2.1 拆分采用 grunt 方式,规则更新
Browse files Browse the repository at this point in the history
- 修正百度搜索规则
- 增加爱活网规则
  • Loading branch information
ywzhaiqi committed Jun 24, 2014
1 parent 3106f64 commit 595097f
Show file tree
Hide file tree
Showing 7 changed files with 6,633 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
tmp/
*.sublime-workspace
*.sublime-workspace
*.cache
64 changes: 64 additions & 0 deletions Super_preloaderPlus/Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
module.exports = function(grunt) {

var concatOptions = {
banner: '(function() {',
footer: '})();',
separator: '//----------------------------------'
};

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: ['tmp'],
concat: {
dist: {
options: concatOptions,
src: ['src/meta.js', 'src/rule.js', 'src/main.js'],
dest: '<%= pkg.name %>.user.js'
},
},
watch: {
files: ['src/**/*.js'],
tasks: ['default']
}
})


grunt.registerTask('split', 'split file', function () {
grunt.file.expand('src/*').forEach(function(path){
grunt.file.delete(path);
});

var source = grunt.file.read('super_preloaderplus_one.user.js');

// 去除首行和尾行
source = source.replace(/^\(function\(\).*/, '')
.replace(/\}\)\(\);$/, '');

var arr = source.split(/\n\/\/\-+/);

arr.forEach(function (text, index) {
if (index === 0) {
grunt.file.write('src/meta.js', text);
} else {
var match = text.match(/\n\/\/\s*(.*)/);
var name = match ? match[1] : ('split' + index + '.js' );
grunt.file.write('src/' + name, text);
}
});

// grunt.log.writeln();
});


grunt.registerTask('default', [
//'jshint',
'concat',
])

grunt.registerTask('watch', ['watch'])

grunt.loadNpmTasks('grunt-contrib-concat')
grunt.loadNpmTasks('grunt-contrib-clean')
grunt.loadNpmTasks('grunt-contrib-watch')

}
10 changes: 10 additions & 0 deletions Super_preloaderPlus/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "super_preloaderplus_one",
"version": "6.2.0",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-concat": "~0.4.0",
"grunt-contrib-watch": "~0.6.1"
}
}
Loading

0 comments on commit 595097f

Please sign in to comment.