mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-10 17:48:50 +08:00
refactor(exports): move exports to src/global
This commit is contained in:
parent
320216c2c8
commit
56364ff0c7
11 changed files with 32 additions and 36 deletions
|
@ -119,7 +119,6 @@ module.exports = (grunt) ->
|
|||
src: [
|
||||
'src/**/*.coffee'
|
||||
'internal_packages/**/*.coffee'
|
||||
'exports/**/*.coffee'
|
||||
'static/**/*.coffee'
|
||||
]
|
||||
dest: appDir
|
||||
|
@ -205,7 +204,6 @@ module.exports = (grunt) ->
|
|||
'internal_packages/**/*.cjsx'
|
||||
'internal_packages/**/*.coffee'
|
||||
'dot-nylas/**/*.coffee'
|
||||
'exports/**/*.coffee'
|
||||
'src/**/*.coffee'
|
||||
'src/**/*.cjsx'
|
||||
'spec/**/*.coffee'
|
||||
|
@ -220,7 +218,6 @@ module.exports = (grunt) ->
|
|||
'internal_packages/**/*.cjsx'
|
||||
'internal_packages/**/*.coffee'
|
||||
'dot-nylas/**/*.coffee'
|
||||
'exports/**/*.coffee'
|
||||
'src/**/*.coffee'
|
||||
'src/**/*.cjsx'
|
||||
]
|
||||
|
|
|
@ -19,7 +19,6 @@ module.exports = (grunt) ->
|
|||
if '' in folder.paths
|
||||
folder.paths = [
|
||||
''
|
||||
'exports'
|
||||
'spec'
|
||||
'src'
|
||||
'src/browser'
|
||||
|
|
|
@ -22,11 +22,11 @@ try
|
|||
|
||||
{runSpecSuite} = require './jasmine-helper'
|
||||
|
||||
# Add 'exports' to module search path.
|
||||
exportsPath = path.join(atom.getLoadSettings().resourcePath, 'exports')
|
||||
require('module').globalPaths.push(exportsPath)
|
||||
# Add 'src/global' to module search path.
|
||||
globalPath = path.join(atom.getLoadSettings().resourcePath, 'src', 'global')
|
||||
require('module').globalPaths.push(globalPath)
|
||||
# Still set NODE_PATH since tasks may need it.
|
||||
process.env.NODE_PATH = exportsPath
|
||||
process.env.NODE_PATH = globalPath
|
||||
|
||||
document.title = "Spec Suite"
|
||||
runSpecSuite './spec-suite', atom.getLoadSettings().logFile
|
||||
|
|
|
@ -161,12 +161,12 @@ class Atom extends Model
|
|||
document.body.classList.add("platform-#{process.platform}")
|
||||
document.body.classList.add("window-type-#{windowType}")
|
||||
|
||||
# Add 'exports' to module search path.
|
||||
exportsPath = path.join(resourcePath, 'exports')
|
||||
require('module').globalPaths.push(exportsPath)
|
||||
# Add 'src/global' to module search path.
|
||||
globalPath = path.join(resourcePath, 'src', 'global')
|
||||
require('module').globalPaths.push(globalPath)
|
||||
|
||||
# Still set NODE_PATH since tasks may need it.
|
||||
process.env.NODE_PATH = exportsPath
|
||||
process.env.NODE_PATH = globalPath
|
||||
|
||||
# Make react.js faster
|
||||
process.env.NODE_ENV ?= 'production' unless devMode
|
||||
|
|
|
@ -7,7 +7,7 @@ Model = require '../models/model'
|
|||
Utils = require '../models/utils'
|
||||
Actions = require '../actions'
|
||||
ModelQuery = require '../models/query'
|
||||
NylasStore = require '../../../exports/nylas-store'
|
||||
NylasStore = require 'nylas-store'
|
||||
DatabaseSetupQueryBuilder = require './database-setup-query-builder'
|
||||
PriorityUICoordinator = require '../../priority-ui-coordinator'
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
{deprecate} = require 'grim'
|
||||
|
||||
module.exports =
|
||||
BufferedNodeProcess: require '../src/buffered-node-process'
|
||||
BufferedProcess: require '../src/buffered-process'
|
||||
BufferedNodeProcess: require '../buffered-node-process'
|
||||
BufferedProcess: require '../buffered-process'
|
||||
Point: Point
|
||||
Range: Range
|
||||
Emitter: Emitter
|
||||
|
@ -14,4 +14,4 @@ module.exports =
|
|||
# The following classes can't be used from a Task handler and should therefore
|
||||
# only be exported when not running as a child node process
|
||||
unless process.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE
|
||||
module.exports.Task = require '../src/task'
|
||||
module.exports.Task = require '../task'
|
|
@ -2,12 +2,12 @@
|
|||
class NylasComponentKit
|
||||
@load = (prop, path) ->
|
||||
Object.defineProperty @prototype, prop,
|
||||
get: -> require "../src/components/#{path}"
|
||||
get: -> require "../components/#{path}"
|
||||
|
||||
@loadFrom = (prop, path) ->
|
||||
Object.defineProperty @prototype, prop,
|
||||
get: ->
|
||||
exported = require "../src/components/#{path}"
|
||||
exported = require "../components/#{path}"
|
||||
return exported[prop]
|
||||
|
||||
@load "Menu", 'menu'
|
|
@ -6,13 +6,13 @@ DatabaseObjectRegistry = null
|
|||
class NylasExports
|
||||
@registerSerializable = (exported) ->
|
||||
if exported.prototype
|
||||
Task ?= require '../src/flux/tasks/task'
|
||||
Model ?= require '../src/flux/models/model'
|
||||
Task ?= require '../flux/tasks/task'
|
||||
Model ?= require '../flux/models/model'
|
||||
if exported.prototype instanceof Model
|
||||
DatabaseObjectRegistry ?= require '../src/database-object-registry'
|
||||
DatabaseObjectRegistry ?= require '../database-object-registry'
|
||||
DatabaseObjectRegistry.register(exported)
|
||||
else if exported.prototype instanceof Task
|
||||
TaskRegistry ?= require '../src/task-registry'
|
||||
TaskRegistry ?= require '../task-registry'
|
||||
TaskRegistry.register(exported)
|
||||
|
||||
@get = (prop, get) ->
|
||||
|
@ -22,14 +22,14 @@ class NylasExports
|
|||
@load = (prop, path) ->
|
||||
Object.defineProperty @, prop,
|
||||
get: ->
|
||||
exported = require "../src/#{path}"
|
||||
exported = require "../#{path}"
|
||||
NylasExports.registerSerializable(exported)
|
||||
return exported
|
||||
enumerable: true
|
||||
|
||||
# Will require immediately
|
||||
@require = (prop, path) ->
|
||||
exported = require "../src/#{path}"
|
||||
exported = require "../#{path}"
|
||||
NylasExports.registerSerializable(exported)
|
||||
@[prop] = exported
|
||||
|
||||
|
@ -137,17 +137,17 @@ class NylasExports
|
|||
@require "RemoveThreadHelper", 'services/remove-thread-helper'
|
||||
|
||||
# Errors
|
||||
@get "APIError", -> require('../src/flux/errors').APIError
|
||||
@get "OfflineError", -> require('../src/flux/errors').OfflineError
|
||||
@get "TimeoutError", -> require('../src/flux/errors').TimeoutError
|
||||
@get "APIError", -> require('../flux/errors').APIError
|
||||
@get "OfflineError", -> require('../flux/errors').OfflineError
|
||||
@get "TimeoutError", -> require('../flux/errors').TimeoutError
|
||||
|
||||
# Process Internals
|
||||
@load "LaunchServices", 'launch-services'
|
||||
@load "BufferedProcess", 'buffered-process'
|
||||
@load "BufferedNodeProcess", 'buffered-node-process'
|
||||
@get "APMWrapper", -> require('../src/apm-wrapper')
|
||||
@get "APMWrapper", -> require('../apm-wrapper')
|
||||
|
||||
# Testing
|
||||
@get "NylasTestUtils", -> require '../spec-nylas/test_utils'
|
||||
@get "NylasTestUtils", -> require '../../spec-nylas/test_utils'
|
||||
|
||||
module.exports = NylasExports
|
|
@ -1,5 +1,5 @@
|
|||
{Listener, Publisher} = require '../src/flux/modules/reflux-coffee'
|
||||
CoffeeHelpers = require '../src/flux/coffee-helpers'
|
||||
{Listener, Publisher} = require '../flux/modules/reflux-coffee'
|
||||
CoffeeHelpers = require '../flux/coffee-helpers'
|
||||
|
||||
# A simple Flux implementation
|
||||
class NylasStore
|
|
@ -121,7 +121,7 @@ loadExtensions = (modulePath, rootPath, rootMetadata, moduleCache) ->
|
|||
return if 'tests' in segments
|
||||
return if 'spec' in segments
|
||||
return if 'specs' in segments
|
||||
return if segments.length > 1 and not (segments[0] in ['exports', 'lib', 'node_modules', 'src', 'static', 'vendor'])
|
||||
return if segments.length > 1 and not (segments[0] in ['lib', 'node_modules', 'src', 'static', 'vendor'])
|
||||
|
||||
extension = path.extname(filePath)
|
||||
if extension in extensions
|
||||
|
@ -196,9 +196,9 @@ resolveModulePath = (relativePath, parentModule) ->
|
|||
registerBuiltins = (devMode) ->
|
||||
if devMode or not cache.resourcePath.startsWith("#{process.resourcesPath}#{path.sep}")
|
||||
fs = require 'fs-plus'
|
||||
atomCoffeePath = path.join(cache.resourcePath, 'exports', 'atom.coffee')
|
||||
atomCoffeePath = path.join(cache.resourcePath, 'src', 'global', 'atom.coffee')
|
||||
cache.builtins.atom = atomCoffeePath if fs.isFileSync(atomCoffeePath)
|
||||
cache.builtins.atom ?= path.join(cache.resourcePath, 'exports', 'atom.js')
|
||||
cache.builtins.atom ?= path.join(cache.resourcePath, 'src', 'global', 'atom.js')
|
||||
|
||||
electronRoot = path.join(process.resourcesPath, 'atom.asar')
|
||||
|
||||
|
|
|
@ -408,9 +408,9 @@ class PackageManager
|
|||
# If a windowType is passed, we'll only load packages who declare that
|
||||
# windowType as `true` in their package.json file.
|
||||
loadPackages: (windowType) ->
|
||||
# Ensure atom exports is already in the require cache so the load time
|
||||
# Ensure src/global is already in the require cache so the load time
|
||||
# of the first package isn't skewed by being the first to require atom
|
||||
require '../exports/atom'
|
||||
require './global/atom'
|
||||
|
||||
packagePaths = @getAvailablePackagePaths(windowType)
|
||||
|
||||
|
|
Loading…
Reference in a new issue