Create a gist now

Instantly share code, notes, and snippets.

@chitacan /README.md
Last active Feb 22, 2016

What would you like to do?
create a electron project like speed of ⚡️

How to use

$ git clone https://gist.github.com/427fe11ad6beb8b276fb.git <APP_NAME>
$ cd <APP_NAME>
$ npm install -g electron-prebuilt
$ electron .

want more ⚡️er way? create zsh alias !!

electron-gen() {
  git clone https://gist.github.com/427fe11ad6beb8b276fb.git $1
  cd $1
  rm -rf .git/
  electron .
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>hi</title>
</head>
<body>
<h1>hi folks</h1>
</body>
</html>
var App = require('app')
, Menu = require('menu')
, BW = require('browser-window')
, win = null;
require('crash-reporter').start();
App.on('window-all-closed', function() {
if (process.platform != 'darwin')
App.quit();
});
App.on('ready', function() {
win = new BW({width: 800, height: 600});
win.loadUrl('file://' + __dirname + '/index.html');
win.on('closed', function() {
win = null;
});
var menuTmpl = [
{
label: 'Atom Shell',
submenu: [
{
label: 'Quit',
accelerator: 'Command+Q',
click: function() { App.quit(); }
}
]
},
{
label: 'View',
submenu: [
{
label: 'Reload',
accelerator: 'Command+R',
click: function() { win.reload(); }
},
{
label: 'Toggle DevTools',
accelerator: 'Alt+Command+I',
click: function() { win.toggleDevTools(); }
}
]
},
{
label: 'Edit',
submenu: [
{
label: 'Undo',
accelerator: 'Command+Z',
selector: 'undo:'
},
{
label: 'Redo',
accelerator: 'Shift+Command+Z',
selector: 'redo:'
},
{
type: 'separator'
},
{
label: 'Cut',
accelerator: 'Command+X',
selector: 'cut:'
},
{
label: 'Copy',
accelerator: 'Command+C',
selector: 'copy:'
},
{
label: 'Paste',
accelerator: 'Command+V',
selector: 'paste:'
},
{
label: 'Select All',
accelerator: 'Command+A',
selector: 'selectAll:'
},
]
}
];
menu = Menu.buildFromTemplate(menuTmpl);
Menu.setApplicationMenu(menu);
});
{
"name" : "name",
"version": "0.0.1",
"main" : "main.js"
}
@yhbyun
yhbyun commented Jul 24, 2014

방금 클론해서 grunt 돌리니깐 오류가 납니다.

TypeError: Object #<Object> has no method 'on'
    at Object.<anonymous> (/Users/yhbyun/work/atom-shell/demo1/app/main.js:7:5)
    at Module._compile (module.js:455:26)
    at Object.Module._extensions..js (module.js:473:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:363:17)
    at require (module.js:379:17)
    at Immediate._onImmediate (/Users/yhbyun/work/atom-shell/demo1/binaries/Atom.app/Contents/Resources/atom/browser/lib/init.js:69:11)
    at processImmediate [as _immediateCallback] (timers.js:385:17)

그래서 app 폴더를 변경을 했어요. 그리고, atom-shell 버전도 최신으로. Gruntfile.js 수정내용

module.exports = function(grunt) {
  require('load-grunt-tasks')(grunt);

  var fs   = require('fs')
    , path = require('path')
    , dir  = 'binaries';

  grunt.initConfig({
    'download-atom-shell': {
      version: '0.14.1',
      outputDir: dir
    },
    'shell': {
      'mac': {
        command: dir + '/Atom.app/Contents/MacOS/Atom my-app'
      },
      'linux': {
        command: 'chmod +x ' + dir + '/atom && ' + dir + '/atom my-app'
      },
      'win': {
        command: dir + '\\atom.exe my-app'
      }
    }
  });

  grunt.registerTask('default', [
    'install',
    'run'
  ]);

  grunt.registerTask('init', 'initialize project', function() {
    var cwd     = process.cwd()
      , appPath = path.join(cwd, 'my-app')
      , gitPath = path.join(cwd, '.git')

    if (grunt.file.exists(appPath))
      return;

    fs.readdirSync(cwd).forEach(function(file) {
      if (file.charAt(0) !== '_') return;

      var src = path.join(cwd, file);
      var dst = path.join(appPath, file.slice(1))
      grunt.file.copy(src, dst);
      grunt.file.delete(src)
    });
    grunt.file.delete(gitPath);
  })

  grunt.registerTask('install', [
    'init',
    'download-atom-shell'
  ]);

  grunt.registerTask('run', function() {
    if (process.platform === 'darwin')
      grunt.task.run('shell:mac');
    else if (process.platform === 'win32')
      grunt.task.run('shell:win')
    else
      grunt.task.run('shell:linux')
  });
}

이유는 못 찾겟고, 그냥 이렇게 제가 했다는 내용 말씀드릴려고.

@daverogers

NOTE: use version '0.20.3' for download-atom-shell in Gruntfile, otherwise it will fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment