Init package directory for SyntaxMapBuilder

This commit is contained in:
1024jp 2020-02-27 00:43:21 +09:00
parent e6e72f0370
commit 57dc62c8ea
6 changed files with 123 additions and 0 deletions

5
SyntaxMapBuilder/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/

View File

@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "Yams",
"repositoryURL": "https://github.com/jpsim/Yams",
"state": {
"branch": null,
"revision": "c947a306d2e80ecb2c0859047b35c73b8e1ca27f",
"version": "2.0.0"
}
}
]
},
"version": 1
}

View File

@ -0,0 +1,20 @@
// swift-tools-version:5.1
import PackageDescription
let package = Package(
name: "SyntaxMapBuilder",
platforms: [
.macOS("10.15"),
],
products: [
.executable(name: "SyntaxMapBuilder", targets: ["SyntaxMapBuilder"]),
],
dependencies: [
.package(url: "https://github.com/jpsim/Yams", from: "2.0.0"),
],
targets: [
.target(name: "SyntaxMapBuilder", dependencies: ["Yams"]),
.testTarget(name: "SyntaxMapBuilderTests", dependencies: ["SyntaxMapBuilder"]),
]
)

View File

@ -0,0 +1,12 @@
# Syntax Map Builder
Command-line helper application for CotEditor development to build SyntaxMap.json from syntax styles.
This program is aimed to be used only locally on the build phase of CotEditor.
## Usage
```
$ SyntaxMapBuilder Syntaxes/ > SyntaxMap.json
```

View File

@ -0,0 +1,70 @@
//
// SyntaxMapBuilderTests.swift
//
// SyntaxMapBuilder
// https://coteditor.com
//
// Created by 1024jp on 2020-02-26.
//
// ---------------------------------------------------------------------------
//
// © 2020 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import XCTest
import class Foundation.Bundle
final class SyntaxMapBuilderTests: XCTestCase {
static var allTests = [
("testExample", testExample),
]
func testExample() throws {
let fooBinary = productsDirectory.appendingPathComponent("SyntaxMapBuilder")
let process = Process()
process.executableURL = fooBinary
let pipe = Pipe()
process.standardOutput = pipe
try process.run()
process.waitUntilExit()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
let output = String(data: data, encoding: .utf8)
XCTAssertEqual(output, "")
}
// MARK: Private Methods
/// Returns path to the built products directory.
private var productsDirectory: URL {
#if os(macOS)
for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") {
return bundle.bundleURL.deletingLastPathComponent()
}
fatalError("couldn't find the products directory")
#else
return Bundle.main.bundleURL
#endif
}
}