Skip to content

Commit ed14e2c

Browse files
authored
move require-self to tasks (#92)
1 parent 5795705 commit ed14e2c

2 files changed

Lines changed: 19 additions & 17 deletions

File tree

Gruntfile.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,7 @@ module.exports = function (grunt) {
9393
grunt.loadNpmTasks('grunt-contrib-watch');
9494
grunt.loadNpmTasks('grunt-umd');
9595

96-
grunt.registerTask('require-self', 'Sets-up requireself', function() {
97-
// TODO: move to package
98-
var fs = require('fs');
99-
var path = require('path');
100-
101-
// Get the name of the module in the current working directory.
102-
var cwd = process.cwd();
103-
var pkg = require(path.join(cwd, 'package.json'));
104-
var name = pkg.name;
105-
106-
// Compute the location and content for the pseudo-module.
107-
var modulePath = path.join(cwd, 'node_modules', name + '.js');
108-
var moduleText = "module.exports = require('..');";
109-
110-
// Create the pseudo-module.
111-
fs.writeFileSync(modulePath, moduleText);
112-
});
96+
grunt.registerTask('require-self', 'Sets-up requireself', require('./tasks/require-self'));
11397

11498
// Tasks
11599
grunt.registerTask('test:lite', ['require-self', 'karma:global', 'jshint']);

tasks/require-self.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
/* jshint node: true */
3+
module.exports = function() {
4+
var fs = require('fs');
5+
var path = require('path');
6+
7+
// Get the name of the module in the current working directory.
8+
var cwd = process.cwd();
9+
var pkg = require(path.join(cwd, 'package.json'));
10+
var name = pkg.name;
11+
12+
// Compute the location and content for the pseudo-module.
13+
var modulePath = path.join(cwd, 'node_modules', name + '.js');
14+
var moduleText = "module.exports = require('..');";
15+
16+
// Create the pseudo-module.
17+
fs.writeFileSync(modulePath, moduleText);
18+
};

0 commit comments

Comments
 (0)