mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
👕 Use standard style for js code
This commit is contained in:
@@ -17,14 +17,14 @@ var PREFIX_LENGTH = Math.max.apply(Math, PREFIXES.map(function (prefix) {
|
||||
return prefix.length
|
||||
}))
|
||||
|
||||
exports.shouldCompile = function(sourceCode) {
|
||||
exports.shouldCompile = function (sourceCode) {
|
||||
var start = sourceCode.substr(0, PREFIX_LENGTH)
|
||||
return PREFIXES.some(function (prefix) {
|
||||
return start.indexOf(prefix) === 0
|
||||
})
|
||||
}
|
||||
|
||||
exports.getCachePath = function(sourceCode) {
|
||||
exports.getCachePath = function (sourceCode) {
|
||||
if (babelVersionDirectory == null) {
|
||||
var babelVersion = require('babel-core/package.json').version
|
||||
babelVersionDirectory = path.join('js', 'babel', createVersionAndOptionsDigest(babelVersion, defaultOptions))
|
||||
@@ -35,11 +35,11 @@ exports.getCachePath = function(sourceCode) {
|
||||
crypto
|
||||
.createHash('sha1')
|
||||
.update(sourceCode, 'utf8')
|
||||
.digest('hex') + ".js"
|
||||
.digest('hex') + '.js'
|
||||
)
|
||||
}
|
||||
|
||||
exports.compile = function(sourceCode, filePath) {
|
||||
exports.compile = function (sourceCode, filePath) {
|
||||
if (!babel) {
|
||||
babel = require('babel-core')
|
||||
}
|
||||
|
||||
@@ -4,21 +4,21 @@ var crypto = require('crypto')
|
||||
var path = require('path')
|
||||
var CoffeeScript = null
|
||||
|
||||
exports.shouldCompile = function() {
|
||||
exports.shouldCompile = function () {
|
||||
return true
|
||||
}
|
||||
|
||||
exports.getCachePath = function(sourceCode) {
|
||||
exports.getCachePath = function (sourceCode) {
|
||||
return path.join(
|
||||
"coffee",
|
||||
'coffee',
|
||||
crypto
|
||||
.createHash('sha1')
|
||||
.update(sourceCode, 'utf8')
|
||||
.digest('hex') + ".js"
|
||||
.digest('hex') + '.js'
|
||||
)
|
||||
}
|
||||
|
||||
exports.compile = function(sourceCode, filePath) {
|
||||
exports.compile = function (sourceCode, filePath) {
|
||||
if (!CoffeeScript) {
|
||||
var previousPrepareStackTrace = Error.prepareStackTrace
|
||||
CoffeeScript = require('coffee-script')
|
||||
|
||||
@@ -93,8 +93,9 @@ function writeCachedJavascript (relativeCachePath, code) {
|
||||
}
|
||||
|
||||
function addSourceURL (jsCode, filePath) {
|
||||
if (process.platform === 'win32')
|
||||
if (process.platform === 'win32') {
|
||||
filePath = '/' + path.resolve(filePath).replace(/\\/g, '/')
|
||||
}
|
||||
return jsCode + '\n' + '//# sourceURL=' + encodeURI(filePath) + '\n'
|
||||
}
|
||||
|
||||
@@ -114,7 +115,7 @@ require('source-map-support').install({
|
||||
try {
|
||||
var sourceCode = fs.readFileSync(filePath, 'utf8')
|
||||
} catch (error) {
|
||||
console.warn("Error reading source file", error.stack)
|
||||
console.warn('Error reading source file', error.stack)
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -123,7 +124,7 @@ require('source-map-support').install({
|
||||
try {
|
||||
var fileData = readCachedJavascript(compiler.getCachePath(sourceCode, filePath))
|
||||
} catch (error) {
|
||||
console.warn("Error reading compiled file", error.stack)
|
||||
console.warn('Error reading compiled file', error.stack)
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -146,7 +147,7 @@ require('source-map-support').install({
|
||||
try {
|
||||
var sourceMap = JSON.parse(new Buffer(rawData, 'base64'))
|
||||
} catch (error) {
|
||||
console.warn("Error parsing source map", error.stack)
|
||||
console.warn('Error parsing source map', error.stack)
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,11 @@ var defaultOptions = {
|
||||
var TypeScriptSimple = null
|
||||
var typescriptVersionDir = null
|
||||
|
||||
exports.shouldCompile = function() {
|
||||
exports.shouldCompile = function () {
|
||||
return true
|
||||
}
|
||||
|
||||
exports.getCachePath = function(sourceCode) {
|
||||
exports.getCachePath = function (sourceCode) {
|
||||
if (typescriptVersionDir == null) {
|
||||
var version = require('typescript-simple/package.json').version
|
||||
typescriptVersionDir = path.join('ts', createVersionAndOptionsDigest(version, defaultOptions))
|
||||
@@ -32,7 +32,7 @@ exports.getCachePath = function(sourceCode) {
|
||||
)
|
||||
}
|
||||
|
||||
exports.compile = function(sourceCode, filePath) {
|
||||
exports.compile = function (sourceCode, filePath) {
|
||||
if (!TypeScriptSimple) {
|
||||
TypeScriptSimple = require('typescript-simple').TypeScriptSimple
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user