Skip to content

Commit 5251aed

Browse files
authoredApr 19, 2019
Merge pull request #35 from Brett-Best/feature/allow-for-dir-spaces
Feature: Handle spaces in path of a project.
2 parents d5c7166 + 29bfb80 commit 5251aed

File tree

5 files changed

+30
-43
lines changed

5 files changed

+30
-43
lines changed
 

‎bin/nef-jekyll

+2-3
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ buildMicrosite() {
8585

8686
cleanStructure "$output"
8787
mkdir -p "$output"
88-
8988
nef-jekyll-page --from "$pagePath" --to "$output" --permalink "$permalink" 1> "$log" 2>&1
9089
echo -e " - title: $pageName\n url: $permalink\n" >> "$sidebarFilePath" # sidebar page
9190

@@ -218,7 +217,7 @@ makeStructure() {
218217
set +e
219218
local logPath="$1/$LOG_PATH" # parameter `project`
220219
local sitePath="$2" # parameter `site`
221-
local sidebarFolderPath="$2/$BASE_SIDEBAR"
220+
local sidebarFolderPath="$sitePath/$BASE_SIDEBAR"
222221
local baseJekyllPath="$sitePath/$BASE_JEKYLL"
223222

224223
cleanStructure "$logPath"
@@ -282,7 +281,7 @@ if [ -d "$root/$sitePath" ]; then
282281
sitePath="$root/$sitePath"
283282
else
284283
mkdir -p "$sitePath"
285-
sitePath="$root/$sitePath"
284+
sitePath="$sitePath"
286285
fi
287286

288287
generateDocumentation "$projectPath" "$sitePath" "$mainPagePath"

‎bin/nef-playground

+6-6
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ setPlaygroundPlatform() {
101101
local podfilePath=""
102102

103103
if [ "$podfile" != "" ] & [ -f "$podfile" ]; then
104-
podfilePath=$podfile
104+
podfilePath="$podfile"
105105
else
106106
podfilePath="$projectFolder/Podfile"
107107
fi
@@ -112,13 +112,13 @@ setPlaygroundPlatform() {
112112

113113
if [ "ios" = $platform ]; then
114114
rm -rf "$projectFolder/osx"
115-
mv $projectFolder/ios/* $projectFolder
115+
mv "$projectFolder"/ios/* "$projectFolder"
116116
rm -rf "$projectFolder/ios"
117117
echo " ${green}iOS${reset}"
118118

119119
elif [ "osx" = $platform ]; then
120120
rm -rf "$projectFolder/ios" 1>/dev/null 2>/dev/null
121-
mv $projectFolder/osx/* $projectFolder
121+
mv "$projectFolder"/osx/* "$projectFolder"
122122
rm -rf "$projectFolder/osx" 1>/dev/null 2>/dev/null
123123
echo " ${green}macOS${reset}"
124124

@@ -152,7 +152,7 @@ playground() {
152152
local tempLog="$root/init-playground.log"
153153
local log="$projectFolder/nef/playground/init-playground.log"
154154

155-
cd $root
155+
cd "$root"
156156
echo -ne "${normal}Installing ${green}Playground ($projectName)${reset}..."
157157

158158
if [ -d "$projectName" ]; then
@@ -201,15 +201,15 @@ cleanStructure() {
201201

202202
cleanProject() {
203203
local projectFolder="$1" # parameter `folder`
204-
rm -rf $projectFolder
204+
rm -rf "$projectFolder"
205205
}
206206

207207

208208
#: - MAIN
209209
set -e
210210

211211
root=`pwd`
212-
projectName=$DEFAULT_PLAYGROUND
212+
projectName="$DEFAULT_PLAYGROUND"
213213
version=$(lastestBowVersion)
214214
branch=""
215215
podfile=""

‎bin/nefc

+17-17
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ addPlaygroundReference() {
235235

236236
find . -name '*.pbxproj' -print0 | while IFS= read -r -d $'\0' project; do
237237
workspace=$(workspaceForProjectPath "$1" "$project")
238-
workspaceName=$(echo $workspace | rev | cut -d'/' -f 1 | rev | cut -d'.' -f 1)
238+
workspaceName=$(echo "$workspace" | rev | cut -d'/' -f 1 | rev | cut -d'.' -f 1)
239239
workspaceContent="$workspace/contents.xcworkspacedata"
240-
! [[ $workspace = .*".xcworkspace" ]] && continue
240+
! [[ "$workspace" = .*".xcworkspace" ]] && continue
241241
grep -q ".playground" "$workspaceContent"; [ $? -eq 0 ] && continue
242242

243243
for playground in "${playgroundForProjectPath[@]}"; do
@@ -276,24 +276,24 @@ makeStructure() {
276276
set +e
277277
local projectFolder=$1 # parameter `folder`
278278

279-
cd $projectFolder
279+
cd "$projectFolder"
280280

281-
cleanStructure $projectFolder
281+
cleanStructure "$projectFolder"
282282
mkdir -p nef/build/fw
283283
mkdir -p nef/build/output
284284
mkdir -p nef/log
285-
mkdir -p $DERIVED_DATA_DIR
285+
mkdir -p "$DERIVED_DATA_DIR"
286286
}
287287

288288
cleanStructure() {
289289
set +e
290290
local projectFolder=$1 # parameter `folder`
291291

292-
cd $projectFolder
292+
cd "$projectFolder"
293293

294294
rm -r nef/build 1>/dev/null 2>/dev/null
295295
rm -r nef/log 1>/dev/null 2>/dev/null
296-
rm -r $DERIVED_DATA_DIR 1>/dev/null 2>/dev/null
296+
rm -r "$DERIVED_DATA_DIR" 1>/dev/null 2>/dev/null
297297
}
298298

299299
##
@@ -303,7 +303,7 @@ cleanStructure() {
303303
copyFrameworks() {
304304
local projectFolder=$1 # parameter `folder`
305305

306-
cd $projectFolder
306+
cd "$projectFolder"
307307

308308
if [ ! -d "$DERIVED_DATA_DIR/build" ]; then
309309
echo "Copy ${green}frameworks${reset}"
@@ -352,7 +352,7 @@ makeHeaders() {
352352
compilePlaygroundPages() {
353353
local projectFolder=$1 # parameter `folder`
354354

355-
cd $projectFolder
355+
cd "$projectFolder"
356356

357357
pages=()
358358
while read -r -d $'\0' playground; do
@@ -362,14 +362,14 @@ compilePlaygroundPages() {
362362
echo "${bold}Found ${#pages[@]} playgrounds${normal}"
363363

364364
for file in "${pages[@]}"; do
365-
pageName=$(echo $file | rev | cut -d'/' -f 1 | rev)
365+
pageName=$(echo "$file" | rev | cut -d'/' -f 1 | rev)
366366
echo -ne "${normal} Compiling ${green}$pageName${reset} ..."
367367

368368
# paths
369-
baseFile=$(echo $file | cut -c 2-)
369+
baseFile=$(echo "$file" | cut -c 2-)
370370
baseAbsolute=$(echo "$projectFolder$baseFile")
371-
content=$baseAbsolute/Contents.swift
372-
playgroundName=$(echo $baseAbsolute | rev | cut -d'/' -f 1 | cut -d'.' -f 2 | rev)
371+
content="$baseAbsolute/Contents.swift"
372+
playgroundName=$(echo "$baseAbsolute" | rev | cut -d'/' -f 1 | cut -d'.' -f 2 | rev)
373373

374374
# headers
375375
output=$(makeHeaders "$content" "$playgroundName")
@@ -393,17 +393,17 @@ compilePlaygroundPage() {
393393
local playgroundPage="$3" # parameter `playground`
394394
local llog="nef/log/$playgroundName-dlyb.log"
395395
local log="nef/log/$playgroundName.log"
396-
local sources="$playgroundPage/../../Sources/*"
396+
local sources="$playgroundPage/../../Sources"
397397
local staticLib="$playgroundName"$(date '+_%H_%M_%S')
398398
local staticLibPath="nef/build/fw/$staticLib"
399399

400400
platformIOS=$(isPlatfromIOSPlaygroundPage "$playgroundPage")
401-
hasSourceFolderFiles=$(ls $sources 2> /dev/null)
401+
hasSourceFolderFiles=$(ls "$sources" 2> /dev/null)
402402

403403
# A. macOS paltform
404404
if [ "$platformIOS" -eq "0" ]; then
405405
if [ "${#hasSourceFolderFiles}" -gt 0 ]; then
406-
xcrun -k swiftc -D NOT_IN_PLAYGROUND -emit-module $sources -F "nef/build/fw" -o "$staticLibPath" 1> "$llog" 2>&1
406+
xcrun -k swiftc -D NOT_IN_PLAYGROUND -emit-module "$sources"/* -F "nef/build/fw" -o "$staticLibPath" 1> "$llog" 2>&1
407407
xcrun -k swiftc -D NOT_IN_PLAYGROUND -static-executable "$staticLibPath" -F "nef/build/fw" "$file" -o "nef/build/output/$playgroundName" 1> "$log" 2>&1
408408
else
409409
xcrun -k swiftc -D NOT_IN_PLAYGROUND -F "nef/build/fw" "$file" -o "nef/build/output/$playgroundName" 1> "$log" 2>&1
@@ -412,7 +412,7 @@ compilePlaygroundPage() {
412412
# B. iOS platform
413413
else
414414
if [ "${#hasSourceFolderFiles}" -gt 0 ]; then
415-
xcrun -k -sdk "iphonesimulator" swiftc -D NOT_IN_PLAYGROUND -target "x86_64-apple-ios12.1-simulator" -emit-module $sources -F "nef/build/fw" -o "$staticLibPath" 1> "$llog" 2>&1
415+
xcrun -k -sdk "iphonesimulator" swiftc -D NOT_IN_PLAYGROUND -target "x86_64-apple-ios12.1-simulator" -emit-module "$sources"/* -F "nef/build/fw" -o "$staticLibPath" 1> "$llog" 2>&1
416416
xcrun -k -sdk "iphonesimulator" swiftc -D NOT_IN_PLAYGROUND -target "x86_64-apple-ios12.1-simulator" -static-executable "$staticLibPath" -F "nef/build/fw" "$file" -o "nef/build/output/$playgroundName" 1> "$log" 2>&1
417417
else
418418
xcrun -k -sdk "iphonesimulator" swiftc -D NOT_IN_PLAYGROUND -target "x86_64-apple-ios12.1-simulator" -F "nef/build/fw" "$file" -o "nef/build/output/$playgroundName" 1> "$log" 2>&1

‎markdown/Common/ConsoleReader.swift

+4-16
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,19 @@ enum Console: ConsoleOutput {
4141
/// - Returns: the parameters to configure the script: path to parser file and output path for render.
4242
func arguments(keys: String...) -> [String: String] {
4343
var result: [String: String] = [:]
44-
45-
func int8Ptr(fromString str: String) -> UnsafePointer<Int8>? {
46-
let data = str.data(using: .utf8)
47-
let ptr: UnsafePointer<Int8>? = data?.withUnsafeBytes { (bytes: UnsafeRawBufferPointer) -> UnsafePointer<Int8>? in
48-
return bytes.bindMemory(to: Int8.self).baseAddress
49-
}
50-
51-
return ptr
52-
}
53-
44+
5445
var longopts: [option] {
55-
let lopts: [option] = keys.enumerated().map { (arg) -> option in
56-
57-
let (offset, element) = arg
58-
return option(name: int8Ptr(fromString: element),
46+
let lopts: [option] = keys.enumerated().map { (offset, element) -> option in
47+
return option(name: strdup(element),
5948
has_arg: required_argument,
6049
flag: nil,
6150
val: Int32(offset))
6251
}
63-
6452
return lopts + [option()]
6553
}
6654

6755
let optLongKey = keys.map { key in String(key[key.startIndex]) }.joined(separator: "")
68-
56+
6957
while case let opt = getopt_long(CommandLine.argc, CommandLine.unsafeArgv, "\(optLongKey):", longopts, nil), opt != -1 {
7058
let match = keys.enumerated().first { (index, _) in opt == Int32(index) }
7159
guard let key = match?.element else { return [:] }

‎setup/TemplateConfigurator.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def run_pod_install
4747
end
4848

4949
def clean_unuseful_files
50-
[".git", ".gitignore", ".travis.yml", "LICENSE", "README.md", "bin", "configure", "lib", "markdown", "setup"].each do |asset|
50+
[".git", ".gitignore", ".travis.yml", "LICENSE", "README.md", "bin", "configure", "lib", "markdown", "setup", "assets"].each do |asset|
5151
`rm -rf #{asset}`
5252
end
5353
end

0 commit comments

Comments
 (0)
Please sign in to comment.