Evan You преди 12 години
ревизия
83fac017f9
променени са 8 файла, в които са добавени 124 реда и са изтрити 0 реда
  1. 5 0
      .gitignore
  2. 14 0
      .jshintrc
  3. 50 0
      Gruntfile.js
  4. 11 0
      component.json
  5. 12 0
      package.json
  6. 1 0
      src/main.js
  7. 24 0
      test/test.html
  8. 7 0
      test/test.js

+ 5 - 0
.gitignore

@@ -0,0 +1,5 @@
+.DS_Store
+.sass-cache
+node_modules
+components
+dist

+ 14 - 0
.jshintrc

@@ -0,0 +1,14 @@
+{
+    "eqeqeq": true,
+    "browser": true,
+    "asi": true,
+    "multistr": true,
+    "undef": true,
+    "unused": true,
+    "trailing": true,
+    "sub": true,
+    "node": true,
+    "globals": {
+        "console": true
+    }
+}

+ 50 - 0
Gruntfile.js

@@ -0,0 +1,50 @@
+module.exports = function( grunt ) {
+
+    grunt.initConfig({
+
+        component_build: {
+            build: {
+                output: './dist/',
+                name: 'element',
+                styles: false,
+                scripts: true,
+                verbose: true
+            }
+        },
+
+        jshint: {
+            build: {
+                src: ['src/**/*.js'],
+                options: {
+                    jshintrc: "./.jshintrc"
+                }
+            }
+        },
+
+        mocha: {
+            build: {
+                src: ['test/test.html'],
+                options: {
+                    reporter: 'Spec',
+                    run: true
+                }
+            }
+        },
+
+        watch: {
+            component: {
+                files: ['src/**/*.js', 'component.json'],
+                tasks: 'component_build'
+            }
+        }
+
+    })
+
+    grunt.loadNpmTasks( 'grunt-contrib-watch' )
+    grunt.loadNpmTasks( 'grunt-contrib-jshint' )
+    grunt.loadNpmTasks( 'grunt-component-build' )
+    grunt.loadNpmTasks( 'grunt-mocha' )
+    grunt.registerTask( 'test', ['mocha'] )
+    grunt.registerTask( 'default', ['jshint', 'component_build', 'mocha'] )
+    
+}

+ 11 - 0
component.json

@@ -0,0 +1,11 @@
+{
+	"name": "element",
+	"version": "0.0.1",
+	"dependencies": {
+		"component/emitter": "*"
+	},
+	"main": "src/main.js",
+	"scripts": [
+		"src/main.js"
+	]
+}

+ 12 - 0
package.json

@@ -0,0 +1,12 @@
+{
+  "name": "element",
+  "version": "0.0.1",
+  "devDependencies": {
+    "grunt": "~0.4.1",
+    "grunt-contrib-watch": "~0.4.4",
+    "grunt-component-build": "~0.3.0",
+    "grunt-contrib-jshint": "~0.6.0",
+    "grunt-mocha": "~0.4.0",
+    "chai": "~1.7.2"
+  }
+}

+ 1 - 0
src/main.js

@@ -0,0 +1 @@
+module.exports = 123

+ 24 - 0
test/test.html

@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+	<head>
+		<title>Test</title>
+		<meta charset="utf-8">
+		<link rel="stylesheet" type="text/css" href="../node_modules/grunt-mocha/node_modules/mocha/mocha.css">
+	</head>
+	<body>
+		<div id="mocha"></div>
+		<script src="../node_modules/grunt-mocha/node_modules/mocha/mocha.js"></script>
+		<script src="../node_modules/chai/chai.js"></script>
+		<script>
+			mocha.setup('bdd')
+			var assert = chai.assert
+		</script>
+		<script src="../dist/element.js"></script>
+		<script src="test.js"></script>
+		<script>
+			if (navigator.userAgent.indexOf('PhantomJS') < 0) {
+            	mocha.run();
+        	}
+		</script>
+	</body>
+</html>

+ 7 - 0
test/test.js

@@ -0,0 +1,7 @@
+var Element = require('element')
+
+describe('Element', function () {
+    it('should have a variable', function () {
+        assert.equal(Element, 123)
+    })
+})